Feeds:
Posts
Comments

Namespace

using System.Data.SqlClient;

using CrystalDecisions.Shared;

using CrystalDecisions.CrystalReports.Engine;

UI Design

ui

Search Criteria have two option like start date to end date select and search.

Search Button coding

Connection cn = new Connection();
 //Button Click Code
   private void Search_Click(object sender, EventArgs e)
   {
     try
            {
            DataSet Ds_records = new DataSet();
            con = new SqlConnection(cn.getConnection());
            SqlDataAdapter da = new SqlDataAdapter(“Sp_DiscountTharapy_Report_datewise”, con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.SelectCommand.Parameters.Add(“@firstDate”, SqlDbType.DateTime).Value = dateTimePicker1.Text;
            da.SelectCommand.Parameters.Add(“@EndDate”, SqlDbType.DateTime).Value = dateTimePicker2.Text;
            da.SelectCommand.Parameters.Add(“@hospital_id”, SqlDbType.Int).Value = Authentication_log1.hospitalId;
            DataTable dt = new DataTable();
            da.Fill(dt);
            if (dt.Rows.Count > 0)
            {
                rpt_Discounttheraphy_date_wise1.Load(Application.StartupPath + “//rpt_Discounttheraphy_date_wise.rpt”);
                rpt_Discounttheraphy_date_wise1.SetDataSource(dt);
                //from date optional fields
                ParameterFieldDefinitions crParameterFieldDefinitions;
                ParameterFieldDefinition crParameterFieldDefinition;
                ParameterValues crParameterValues = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();
                crParameterDiscreteValue.Value = dateTimePicker1.Text;
                crParameterFieldDefinitions = rpt_Discounttheraphy_date_wise1.DataDefinition.ParameterFields;
                crParameterFieldDefinition = crParameterFieldDefinitions[“test”];
                crParameterValues = crParameterFieldDefinition.CurrentValues;
                crParameterValues.Clear();
                crParameterValues.Add(crParameterDiscreteValue);
                crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);
                // To date optional parameters
                ParameterFieldDefinitions crParameterFieldDefinitions1;
                ParameterFieldDefinition crParameterFieldDefinition1;
                ParameterValues crParameterValues1 = new ParameterValues();
                ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();
                crParameterDiscreteValue1.Value = dateTimePicker2.Text;
                crParameterFieldDefinitions1 = rpt_Discounttheraphy_date_wise1.DataDefinition.ParameterFields;
                crParameterFieldDefinition1 = crParameterFieldDefinitions1[“Todate”];
                crParameterValues1 = crParameterFieldDefinition1.CurrentValues;
                crParameterValues1.Clear();
                crParameterValues1.Add(crParameterDiscreteValue1);
                crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);
                cry_main_report.ReportSource = rpt_Discounttheraphy_date_wise1;
                cry_main_report.Visible = true;
            }
            }
            catch(SqlException ee) {
                MessageBox.Show(“No record Found:”+ee.Message);
            }
        }

Just for Example.

pass textbox value to crystal report?

   ParameterFieldDefinitions crParameterFieldDefinitions1;

                ParameterFieldDefinition crParameterFieldDefinition1;

                ParameterValues crParameterValues1 = new ParameterValues();

                ParameterDiscreteValue crParameterDiscreteValue1 = new ParameterDiscreteValue();              

                crParameterDiscreteValue1.Value =Textbox value;

                crParameterFieldDefinitions1 = rpt_Discounttheraphy_date_wise1.DataDefinition.ParameterFields;

                crParameterFieldDefinition1 = crParameterFieldDefinitions1[“Todate”];

                crParameterValues1 = crParameterFieldDefinition1.CurrentValues;

                crParameterValues1.Clear();

                crParameterValues1.Add(crParameterDiscreteValue1);

                crParameterFieldDefinition1.ApplyCurrentValues(crParameterValues1);

 

 

 

 

Globel Class:

//Namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;

public class Globel
{

public Globel()
{
//
// TODO: Add constructor logic here
//
}

//Declaration of Hastable

public static int i = 5;
private static Hashtable globalhashtable_ = new Hashtable();
//Create Hastable
public static Hashtable globalhashtable
    {
                      get { return globalhashtable_; }

    }

//REMOVE FROM HASHTABLE
  public static bool RemoveItemfromList(string RemoveItemKey)
    {
        if (globalhashtable.Contains(RemoveItemKey.Trim()))
        {
            globalhashtable.Remove(RemoveItemKey.Trim());
            return true;
        }
        return false;
    }
//GET VALUE FROM HASTABLE
   public static string productAttrvaluebyID(string productUD)
    {
        if (globalhashtable.Contains(productUD.Trim()))
        {
            if (globalhashtable.ContainsKey(productUD.Trim()))
            {
                return globalhashtable[productUD].ToString();
            }
            else
            {
                return string.Empty;
            }
        }
        else
        {
            return string.Empty;
        }
    }
}

Code Behind Code:

Add Value to Hastable Like

  Globel.globalhashtable.Add(“Id”,500);

               Globel.globalhashtable.Add(“Key”,600);
   Remove Value from Hastable Like

        Globel.RemoveItemfromList(500);

  Get Value from Hastable Like

    string productAttribute =string.Empty ; 

    productAttribute = Globel.productAttrvaluebyID(productID.ToString());

That is it.

!!Happy Coding..

 

<script>
var str=”Raman(Ghantiy.ala”;

var Strfilter= str.substr(str.lastIndexOf(‘(‘) + 1, str.lastIndexOf(‘.’));

alert(Strfilter);

</script>

if we have this  Raman(Ghantiy.ala  string we want to substring from it. simply lastIndexOf will help us.

Ouput:

Ghantiy

 

Button Click code:

  1. DropDownList drp = new DropDownList();
  2. drp.Items.Insert(0, “–select–“);
  3. drp.AppendDataBoundItems = true;
  4. drp.Items.Add(“Raman Choudhary”,”value1″);
  5. drp.Items.Add(“Asp.net Developer”,”value2″);
  6. drp.AutoPostBack = true;
  7. drp.SelectedIndexChanged += new EventHandler(drp_Click);

Drop Down Create Dynamic Event

void drp_Click(object sender, EventArgs e)
{
DropDownList dp = sender as DropDownList;
if (dp != null)
{
Response.Write(“DropDown id ” + lab_price.Text + dp.SelectedItem.Value + ” selected”);
}

}

 

 

public void CreatThumbnailCat(HttpPostedFileBase fileName)
{

string Thumboutput = Server.MapPath(“~/UploadImages/Category/Thumbnail/” + fileName.FileName.ToString());
string OrgImage = Server.MapPath(“~/UploadImages/Category/” + fileName.FileName.ToString());

// Load image.
Image image = Image.FromStream(fileName.InputStream, true, true);

// Save Orginal image
image.Save(OrgImage);

// Compute thumbnail size.
Size thumbnailSize = GetThumbnailSizeCat(image);

// Get thumbnail.
Image thumbnail = image.GetThumbnailImage(thumbnailSize.Width, thumbnailSize.Height, null, IntPtr.Zero);

// Save thumbnail.
thumbnail.Save(Thumboutput);

}

static Size GetThumbnailSizeCat(Image original)
{
// Maximum size of any dimension.
const int maxPixels = 54;

// Width and height.
int originalWidth = original.Width;
int originalHeight = original.Height;

// Compute best factor to scale entire image based on larger dimension.
double factor;
if (originalWidth > originalHeight)
{
factor = (double)maxPixels / originalWidth;
}
else
{
factor = (double)maxPixels / originalHeight;
}

// Return thumbnail size.
return new Size((int)(originalWidth * factor), (int)(originalHeight * factor));
}

[HttpPost]
public ActionResult AddCatagory(AddCatagory AddModel, FormCollection FormClct)
{

if (ModelState.IsValid)
{
try
{
# region Imagesection
string ImageName = string.Empty;

foreach (string inputTagName in Request.Files)
{
HttpPostedFileBase file = Request.Files[inputTagName];
if (file.ContentLength > 0)
{
CreatThumbnailCat(file);
ImageName += file.FileName.ToString();
}
}
# endregion

}
}

SELECT
CASE WHEN SEX = ‘M’ THEN ‘Male’ ELSE ‘Female’ end as SEX,
CASE WHEN MARITAL_STATUS = ‘M’ THEN ‘Married’ ELSE ‘Unmarried’ end as MARITAL_STATUS,
* FROM  tbl_employeemanagement WHERE     (PkEmpId = 5022)

dynamic menu in asp.net

Cs PAGE COIDNG

if (!IsPostBack)
{
HeaderMenu();

}

public void HeaderMenu()
{
int j = 0;
Literal1.Text = “<ul class=’primary_nav’>”;

SqlDataAdapter ad = new SqlDataAdapter(“SELECT * FROM Category_tb ct WHERE ct.ParentID=0 and ct.active=0  ORDER BY ct.CatName”, con);
ad.Fill(ds);
foreach (DataRow rowAuthor in ds.Tables[0].Rows)
{
if (rowAuthor[“CatName”].ToString() != “#”)
{
Literal1.Text += “<li><a href=’ProductListing.aspx?Id=” + rowAuthor[“CategoryID”].ToString() + “&name=” + rowAuthor[“CatName”].ToString() + “‘ title='” + rowAuthor[“CatName”].ToString() + “‘>” + rowAuthor[“CatName”].ToString() + “</a>”;

//  WHERE ct.ParentID='” + rowAuthor[“CategoryID”].ToString() + “‘
DataSet dsNew = new DataSet();
SqlDataAdapter ad2 = new SqlDataAdapter(“SELECT * FROM Category_tb where  active=0 and ParentID='” + rowAuthor[“CategoryID”].ToString() + “‘ “, con);
ad2.Fill(dsNew);

if (dsNew.Tables[0].Rows.Count > 0)
{
Literal1.Text += “<ul class=’sub_menu’><li><a href=#>My Collection</a><ul>”;

foreach (DataRow rowChild in dsNew.Tables[0].Rows)
{
Literal1.Text += “<li> <a href=’ProductListing.aspx?SUbCatId=” + rowChild[“CategoryID”].ToString() + “&SubCatname=” + rowChild[“CatName”].ToString() + “‘ >” + rowChild[“CatName”].ToString() + “</a> </li>”;
}

Literal1.Text += “</ul></ul> </li>”;
}
else
{
Literal1.Text += “</li>”;

}

}

else
{
//  j++;
//  Literal1.Text += “<li><a href='” + rowAuthor[“CatName”].ToString() + “‘ title='” + rowAuthor[“CatName”].ToString() + “‘ rel=’dropmenu” + j.ToString() + “_a’><span>&nbsp;&nbsp;&nbsp;” + rowAuthor[“CatName”].ToString() + “&nbsp;&nbsp;&nbsp;</span></a></li>”;
}
}
Literal1.Text += “</ul>”;

}

Design Page

<asp:Literal ID=”Literal1″ runat=”server” />

 

change the css according to you.