Example #1
0
        public DateTime MtrlTransfDate(Int64 MtrlTransfIdno)
        {
            DateTime          Value;
            ChallanDelverdDAL objMtrlRcptHODAL = new ChallanDelverdDAL();

            Value            = objMtrlRcptHODAL.MtrlTransfDate(MtrlTransfIdno);
            objMtrlRcptHODAL = null;
            return(Value);
        }
Example #2
0
 private void BindGrid()
 {
     if ((ddlChallanDetl.SelectedIndex > 0) && (txtDate.Text.Trim() != ""))
     {
         ChallanDelverdDAL obj = new ChallanDelverdDAL();
         int   rec             = 0;
         Int64 MtrlRcptIdno    = (Convert.ToString(hidMtrlRcptid.Value) != "" ? Convert.ToInt64(hidMtrlRcptid.Value) : 0);
         rec = obj.IsExeistMtrlTransf(Convert.ToInt64(ddlChallanDetl.SelectedValue), Convert.ToInt32(ddlDateRange.SelectedValue), MtrlRcptIdno);
         if (rec > 0)
         {
             grdMain.Visible = false;
             string msg = "Receipt of the transfer no. : " + ddlChallanDetl.SelectedItem.Text + " is already generated.";
             grdMain.DataSource = null;
             grdMain.DataBind();
             ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg", "PassMessageError('" + msg + "')", true);
         }
         else
         {
             DateTime dMtrlDt = obj.MtrlTransfDate(Convert.ToInt64(ddlChallanDetl.SelectedValue));
             hidMtrlTrnsfDt.Value = dMtrlDt.ToString("dd-MM-yyyy");
             if (Convert.ToDateTime(ApplicationFunction.mmddyyyy(hidMtrlTrnsfDt.Value)) > Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text)))
             {
                 grdMain.Visible    = false;
                 grdMain.DataSource = null; grdMain.DataBind();
                 ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg", "PassMessageError('Date must be Greater than or equal to Transfer Date [" + dMtrlDt.Date.ToString("dd-MMM-yyyy") + "].')", true);
             }
             else
             {
                 DataSet Ds = obj.SelectGridDetl(ApplicationFunction.ConnectionString(), "SelectTransfDetl", Convert.ToInt64(ddlChallanDetl.SelectedValue), Convert.ToInt32(ddlToCity.SelectedValue));
                 obj       = null;
                 LocGrAmnt = 0; OutGrAmnt = 0;
                 if (Ds != null && Ds.Tables[0].Rows.Count > 0)
                 {
                     foreach (DataRow dr in Ds.Tables[0].Rows)
                     {
                         Int32  DelvPlcIdno = Convert.ToInt32(dr["DelvryPlce_Idno"]);
                         double dGrAmnt     = Convert.ToDouble(dr["Amount"]);
                         if (Convert.ToInt32(ddlToCity.SelectedValue) == DelvPlcIdno)
                         {
                             LocGrAmnt += dGrAmnt;
                         }
                         else
                         {
                             OutGrAmnt += dGrAmnt;
                         }
                     }
                 }
                 txtLocGrAmnt.Text  = LocGrAmnt.ToString("N2");
                 txtoutGrAmnt.Text  = OutGrAmnt.ToString("N2");
                 txtNetAmnt.Text    = Convert.ToDouble(LocGrAmnt + OutGrAmnt).ToString("N2");
                 ViewState["dt"]    = (DataTable)Ds.Tables[0];
                 grdMain.DataSource = ViewState["dt"];
                 grdMain.DataBind();
                 grdMain.Visible = true;
             }
         }
         obj = null;
     }
     else
     {
         grdMain.Visible = false;
         ddlChallanDetl.SelectedIndex = 0;
         ddlChallanDetl.Focus();
         grdMain.DataSource = null;
         grdMain.DataBind();
     }
 }
Example #3
0
        protected void lnkBtnSave_Click(object sender, EventArgs e)
        {
            string msg = string.Empty; bool bflag = false; double IssueQty = 0, IssueWT = 0;

            if (grdMain.Rows.Count <= 0)
            {
                ShowMessage("Please Enter Challan Details");
            }
            else
            {
                DtTemp = (DataTable)ViewState["dt"];
                DtTemp = CreateDt();
                ChallanDelverdDAL objChallanDelverdDAL = new ChallanDelverdDAL();
                Int64             MtrlRcptId = 0, MtrlRcptDetlId = 0;
                string            strMsgTyp = String.Empty;
                int yearIdno = Convert.ToInt32(ddlDateRange.SelectedValue);

                Int64           Value           = 0;
                tblChlnDelvHead ObjMtrlRcptHead = new tblChlnDelvHead();
                ObjMtrlRcptHead.ChlnDelv_Date   = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text));
                ObjMtrlRcptHead.ToCity_Idno     = Convert.ToInt32(ddlToCity.SelectedValue);
                ObjMtrlRcptHead.ChlnTransf_Idno = Convert.ToInt32(ddlChallanDetl.SelectedValue);
                ObjMtrlRcptHead.Date_Added      = ApplicationFunction.GetIndianDateTime().Date; // DateTime.Now.Date;
                ObjMtrlRcptHead.Date_Modified   = ApplicationFunction.GetIndianDateTime().Date;
                ObjMtrlRcptHead.ChlnDelv_No     = MaxRcptHeadNo(Convert.ToInt32(ddlToCity.SelectedValue), Convert.ToInt32(ddlDateRange.SelectedValue));
                ObjMtrlRcptHead.CrsngGR_Amnt    = Convert.ToDouble(txtoutGrAmnt.Text);
                ObjMtrlRcptHead.LocGR_Amnt      = Convert.ToDouble(txtLocGrAmnt.Text);
                ObjMtrlRcptHead.Net_Amnt        = Convert.ToDouble(txtNetAmnt.Text);
                ObjMtrlRcptHead.Year_Idno       = Convert.ToInt32(ddlDateRange.SelectedValue);
                foreach (GridViewRow row in grdMain.Rows)
                {
                    HiddenField hidGrIdno   = (HiddenField)row.FindControl("hidGridno");
                    HiddenField hidItemidno = (HiddenField)row.FindControl("hidItemidno");
                    HiddenField hidUnitidno = (HiddenField)row.FindControl("hidUnitidno");
                    Label       lblrateType = (Label)row.FindControl("lblrateType");
                    Label       lblQty      = (Label)row.FindControl("lblQty");
                    Label       lblWeight   = (Label)row.FindControl("lblWeight");
                    Label       lblAmount   = (Label)row.FindControl("lblAmount");
                    TextBox     txtRecQty   = (TextBox)row.FindControl("txtRecQty");
                    TextBox     txtRecWT    = (TextBox)row.FindControl("txtRecWT");
                    TextBox     txtRecWt    = (TextBox)row.FindControl("txtRecWt");
                    TextBox     txtRemark   = (TextBox)row.FindControl("txtRemark");
                    TextBox     txtRecAmt   = (TextBox)row.FindControl("txtRecAmt");
                    if (lblrateType.Text == "Rate")
                    {
                        if (txtRecQty.Text == "")
                        {
                            ShowMessageErr("Please Enter Receiving QTY!");
                            return;
                        }
                        if (Convert.ToDouble(txtRecQty.Text) < 0.00)
                        {
                            ShowMessageErr("You Cannot Enter Receiving QTY Less than 1!");
                            return;
                        }

                        IssueQty = Convert.ToDouble(lblQty.Text);
                        if (IssueQty < Convert.ToDouble(txtRecQty.Text))
                        {
                            txtRecQty.Focus();
                            txtRecQty.Text = "0.00";
                            ShowMessageErr("You Cannot Enter Receiving QTY more than GR QTY!");
                            return;
                        }
                    }
                    else
                    {
                        if (txtRecWT.Text == "")
                        {
                            ShowMessageErr("Please Enter Receiving Weight!");
                            return;
                        }
                        if (Convert.ToDouble(txtRecWT.Text) < 0.00)
                        {
                            ShowMessageErr("You Cannot Enter Receiving Weight Less than 1!");
                            return;
                        }
                        IssueWT = Convert.ToDouble(lblWeight.Text);
                        if (IssueWT < Convert.ToDouble(txtRecWT.Text))
                        {
                            txtRecWT.Focus(); txtRecWT.Text = "0.00";
                            ShowMessageErr("You Cannot Enter Receiving Weight more than GR Weight!");
                            return;
                        }
                    }
                    ApplicationFunction.DatatableAddRow(DtTemp, hidGrIdno.Value, hidItemidno.Value, hidUnitidno.Value, ((lblrateType.Text) == "Rate") ? "1" : "2", lblQty.Text, lblWeight.Text,
                                                        lblAmount.Text, txtRecQty.Text, txtRecWt.Text, txtRecAmt.Text, txtRemark.Text);
                }
                using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
                {
                    try
                    {
                        ChallanDelverdDAL obj     = new ChallanDelverdDAL();
                        DateTime          dMtrlDt = obj.MtrlTransfDate(Convert.ToInt64(ddlChallanDetl.SelectedValue));
                        hidMtrlTrnsfDt.Value = dMtrlDt.ToString("dd-MM-yyyy");
                        if (Convert.ToDateTime(ApplicationFunction.mmddyyyy(hidMtrlTrnsfDt.Value)) > Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text)))
                        {
                            txtDate.Focus();
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg", "PassMessageError('Delivery Date must be greater than or equal to Challan Date [" + dMtrlDt.Date.ToString("dd-MMM-yyyy") + "].')", true);
                            return;
                        }
                        if (string.IsNullOrEmpty(hidMtrlRcptid.Value) == true)
                        {
                            MtrlRcptId = obj.InsertMtrlRcptHOHead(ObjMtrlRcptHead, DtTemp);
                            if (MtrlRcptId > 0)
                            {
                                tScope.Complete();
                            }
                        }
                        else
                        {
                            tblChlnDelvHead ObjMtrlRcptHeadU = new tblChlnDelvHead();
                            ObjMtrlRcptHeadU.ChlnDelv_Date   = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text));
                            ObjMtrlRcptHeadU.ToCity_Idno     = Convert.ToInt32(ddlToCity.SelectedValue);
                            ObjMtrlRcptHeadU.ChlnTransf_Idno = Convert.ToInt32(ddlChallanDetl.SelectedValue);
                            ObjMtrlRcptHeadU.Date_Modified   = ApplicationFunction.GetIndianDateTime().Date;
                            ObjMtrlRcptHeadU.CrsngGR_Amnt    = Convert.ToDouble(txtoutGrAmnt.Text);
                            ObjMtrlRcptHeadU.LocGR_Amnt      = Convert.ToDouble(txtLocGrAmnt.Text);
                            ObjMtrlRcptHeadU.Net_Amnt        = Convert.ToDouble(txtNetAmnt.Text);
                            ObjMtrlRcptHeadU.Year_Idno       = Convert.ToInt32(ddlDateRange.SelectedValue);
                            MtrlRcptId = obj.UpdateMtrlRcptHOHead(ObjMtrlRcptHeadU, DtTemp, Convert.ToInt32(hidMtrlRcptid.Value));
                            if ((MtrlRcptId > 0))
                            {
                                tScope.Complete();
                            }
                        }
                    }

                    catch (Exception ex)
                    {
                        // ApplicationFunction.ErrorLog(ex.ToString());
                    }
                }
                if (string.IsNullOrEmpty(hidMtrlRcptid.Value) == true)
                {
                    if (MtrlRcptId > 0)
                    {
                        ShowMessage("Record Saved Successffully");
                    }
                }
                else
                {
                    if ((MtrlRcptId > 0))
                    {
                        ShowMessage("Record Update successfully");
                    }
                }
                if (MtrlRcptId == -1)
                {
                    ShowMessage("Challan No. already  Delivered !");
                    bflag     = false;
                    strMsgTyp = "RecExst";
                    ddlChallanDetl.Focus();
                }
                else
                {
                    ClearControls();
                }
            }
        }