protected void btngetreport_Click(object sender, EventArgs e)
 {
     try
     {
         if (Rdboutward.SelectedValue == "Outward")
         {
             DataTable dt = OutwardDetail.Get_OutwardDetails(txtoutwardno1.Text.ToString().Trim(), "Outward", "G", Convert.ToInt32(strFY), Convert.ToDateTime("2011/2/2"), Convert.ToDateTime("2012/3/3")).Tables[0];
             GrdOD.DataSource = dt;
             GrdOD.DataBind();
         }//[Idv_Chetana_Get_OutwardDetails]
         else
         if (Rdboutward.SelectedValue == "Invoice")
         {
             DataTable dt = OutwardDetail.Get_OutwardDetails(txtoutwardno1.Text.ToString().Trim(), "ss", "I", Convert.ToInt32(strFY), Convert.ToDateTime("2011/2/2"), Convert.ToDateTime("2012/3/3")).Tables[0];
             GrdOD.DataSource = dt;
             GrdOD.DataBind();
         }
         else
         {
             DataTable dt = OutwardDetail.Get_OutwardDetails(txtoutwardno1.Text.ToString().Trim(), "ss", "D", Convert.ToInt32(strFY), Convert.ToDateTime("2011/2/2"), Convert.ToDateTime("2012/3/3")).Tables[0];
             GrdOD.DataSource = dt;
             GrdOD.DataBind();
         }
     }
     catch { }
 }
    public void Adddata(string txtno)
    {
        TNo       = Convert.ToDecimal(txtno);
        TCustName = lblCustName.Text.Trim();
        TAreaName = lblArea.Text.Trim();

        DataTable dt = new DataTable();

        if (Session["tempODData"] != null)
        {
            Session["tempODData"] = fillTempODData();
            dt = (DataTable)Session["tempODData"];
        }
        else
        {
            Session["tempODData"] = fillTempODData();
            dt = (DataTable)Session["tempODData"];
        }
        GrdOD.DataSource = dt;
        GrdOD.DataBind();
        // txtOutwardDate.Text = DateTime.Now.ToString("dd/MM/yyyy");

        Txtno.Text       = "";
        lblCustName.Text = "";
        lblArea.Text     = "";
        Txtno.Focus();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["ChetanaCompanyName"] != null)
        {
            if (Session["FY"] != null)
            {
                strChetanaCompanyName = Session["ChetanaCompanyName"].ToString();
                strFY = Session["FY"].ToString();
            }
            else
            {
                Session.Clear();
            }
            //Response.Write(strFY);
        }

        if (!Page.IsPostBack)
        {
            //Pnlselect.Visible = true;
            GrdOD.DataBind();

            txtOutwardDate.Text   = DateTime.Now.ToString("dd/MM/yyyy");
            Session["tempODData"] = null;
            btnSave.Visible       = false;
            txtOutwardDate.Focus();
        }
    }
 public void SetView()
 {
     if (Request.QueryString["a"] != null)
     {
         if (Request.QueryString["a"] == "a")
         {
             pnlview.Visible   = false;
             Pnlselect.Visible = true;
             GrdOD.DataBind();
             // pageName.InnerHtml = "ADD Book";
             //txtcode.Focus();
             //lblID.Text = "0";
             //Panel1.Visible = true;
             //pnlBookDetails.Visible = false;
             //btn_Save.Visible = true;
             //Label13.Visible = false;
             //Label14.Visible = false;
             //LblOldqty.Visible = false;
             //filter.Visible = false;
             //btnprint.Visible = false;
             //btnExport.Visible = false;
         }
         else
         if (Request.QueryString["a"] == "v")
         {
             pnlview.Visible   = true;
             Pnlselect.Visible = false;
             GrdOD.DataBind();
             //pageName.InnerHtml = "View / Edit Book";
             //filter.Focus();
             //pnlBookDetails.Visible = true;
             //Panel1.Visible = false;
             //btn_Save.Visible = false;
             //Label13.Visible = true;
             //Label14.Visible = true;
             //LblOldqty.Visible = true;
             //filter.Visible = true;
             //btnprint.Visible = true;
             //btnExport.Visible = true;
         }
     }
 }
    protected void GrdOD_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        OutwardDetail objodd = new OutwardDetail();

        OutDetailID = Convert.ToInt32(((Label)GrdOD.Rows[e.RowIndex].FindControl("lbldetailid")).Text);

        try
        {
            if (OutDetailID != 0)
            {
                objodd.OdDAutoId    = OutDetailID;
                objodd.IsActive     = false;
                objodd.InvoiceNo    = ((Label)GrdOD.Rows[e.RowIndex].FindControl("LblInvoiceNo")).Text.Trim();
                objodd.CustomerName = ((Label)GrdOD.Rows[e.RowIndex].FindControl("LblCustN")).Text.Trim();
                objodd.CustArea     = ((Label)GrdOD.Rows[e.RowIndex].FindControl("LblArea")).Text.Trim();
                objodd.FY           = Convert.ToInt32(strFY);
                objodd.Save();
            }
            DataTable dt3 = new DataTable();
            dt3 = (DataTable)Session["tempODData"];
            dt3.Rows[e.RowIndex].Delete();
            GrdOD.DataSource = dt3;
            GrdOD.DataBind();
            Session["tempODData"] = dt3;

            if (dt3.Rows.Count == 0)
            {
                btnSave.Visible = false;
            }
            else
            {
                btnSave.Visible = true;
            }
        }
        catch { }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        ODdate = txtOutwardDate.Text.Split('/')[2] + "/" + txtOutwardDate.Text.Split('/')[1] + "/" + txtOutwardDate.Text.Split('/')[0];
        ddt    = Convert.ToDateTime(ODdate);

        if (Session["UserName"] != null)
        {
            if (flag != "")
            {
                try
                {
                    OutwardMaster objodm = new OutwardMaster();
                    OutwardDetail objodd = new OutwardDetail();

                    objodm.OdMAutoId   = 0;
                    objodm.OutWardDate = ddt;
                    objodm.IsActive    = true;
                    objodm.CreatedBy   = Session["UserName"].ToString();
                    objodm.FY          = Convert.ToInt32(strFY);
                    objodm.HandOverTo  = TxtEmp.Text.Trim();
                    objodm.Remarks     = TxtRemark.Text.Trim();
                    objodm.Save(out DocNo, out OdMID);
                    //Txtdocno.Text = Convert.ToString(DocNo);

                    foreach (GridViewRow Row in GrdOD.Rows)
                    {
                        objodd.OdDAutoId = 0;
                        objodd.OdMAutoId = OdMID;

                        objodd.InvoiceOrDC  = ((Label)Row.FindControl("LblFlag")).Text.Trim();
                        objodd.InvoiceNo    = ((Label)Row.FindControl("LblInvoiceNo")).Text.Trim();
                        objodd.CustomerName = ((Label)Row.FindControl("LblCustN")).Text.Trim();
                        objodd.CustArea     = ((Label)Row.FindControl("LblArea")).Text.Trim();
                        objodd.IsActive     = true;
                        objodd.FY           = Convert.ToInt32(strFY);
                        //if (RdbtnSelect.SelectedValue == "Invoice")
                        //{
                        //    TFlag = 'I';
                        //    objodd.InvoiceNo = (Txtno.Text.Trim());
                        //}
                        //if (RdbtnSelect.SelectedValue == "Document")
                        //{
                        //    TFlag = 'D';
                        //    objodd.InvoiceNo = (Txtno.Text.Trim());
                        //}
                        objodd.Save();
                    }
                    MessageBox(Constants.save + "\\r\\n Document No: " + DocNo);
                    //MessageBox(Constants.save);

                    //loder("Last saved Document no. : " + Txtdocno.Text);
                    TxtEmp.Text           = "";
                    Txtno.Text            = "";
                    txtOutwardDate.Text   = DateTime.Now.ToString("dd/MM/yyyy");
                    Session["tempODData"] = null;
                    btnSave.Visible       = false;
                    GrdOD.DataBind();
                }
                catch
                {
                }
            }
        }
    }