Пример #1
0
        private void BindMaxNo(string Matfrom, Int32 LocationId, Int32 YearId)
        {
            TyreIssueDAL obj   = new TyreIssueDAL();
            Int64        MaxNo = obj.MaxNo(Matfrom, YearId, LocationId, ApplicationFunction.ConnectionString());

            txtGRNo.Text = Convert.ToString(MaxNo);
        }
Пример #2
0
        private void BindDriver(Int32 var)
        {
            TyreIssueDAL obj = new TyreIssueDAL();

            if (var == 0)
            {
                ddlDriver.DataSource = null;
                var lst = obj.selectOwnerDriverName();
                obj = null;
                if (lst != null && lst.Count > 0)
                {
                    ddlDriver.DataSource     = lst;
                    ddlDriver.DataTextField  = "Acnt_Name";
                    ddlDriver.DataValueField = "Acnt_Idno";
                    ddlDriver.DataBind();
                }
                ddlDriver.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
            }
            else
            {
                ddlDriver.DataSource = null;
                var lst = obj.selectHireDriverName();
                obj = null;
                if (lst != null && lst.Count > 0)
                {
                    ddlDriver.DataSource     = lst;
                    ddlDriver.DataTextField  = "Driver_name";
                    ddlDriver.DataValueField = "Driver_Idno";
                    ddlDriver.DataBind();
                }
                ddlDriver.Items.Insert(0, new ListItem("--Select--", "0"));
            }
        }
Пример #3
0
        private void BindActiveItemDropdown()
        {
            TyreIssueDAL objTruck = new TyreIssueDAL();
            var          itemname = objTruck.BindActiveItemName();

            ddlItemName.DataSource     = itemname;
            ddlItemName.DataTextField  = "Item_name";
            ddlItemName.DataValueField = "Item_idno";
            ddlItemName.DataBind();
            ddlItemName.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
        }
Пример #4
0
        private void BindSerialNo()
        {
            TyreIssueDAL objSerial = new TyreIssueDAL();
            var          SerialNo  = objSerial.BindSerialNo(Convert.ToInt64(ddlItemName.SelectedValue), Convert.ToInt64(ddlLocation.SelectedValue));

            ddlSerialNo.DataSource     = SerialNo;
            ddlSerialNo.DataTextField  = "Serial_No";
            ddlSerialNo.DataValueField = "Serial_Idno";
            ddlSerialNo.DataBind();
            ddlSerialNo.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
        }
Пример #5
0
        protected void ImgBtnTruuckRefresh_Click(object sender, ImageClickEventArgs e)
        {
            TyreIssueDAL obj        = new TyreIssueDAL();
            var          TruckNolst = obj.BindTruckNo();

            ddlTruckNo.DataSource     = TruckNolst;
            ddlTruckNo.DataTextField  = "Lorry_No";
            ddlTruckNo.DataValueField = "lorry_idno";
            ddlTruckNo.DataBind();
            ddlTruckNo.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
        }
Пример #6
0
        private void BindDropdown()
        {
            BindDropdownDAL obj        = new BindDropdownDAL();
            TyreIssueDAL    objTruck   = new TyreIssueDAL();
            var             TruckNolst = obj.BindTruckNo();
            var             ToCity     = obj.BindLocFrom();
            var             itemname   = objTruck.BindItemName();

            obj = null;
            ddlTruckNo.DataSource     = objTruck.BindTruckNo();
            ddlTruckNo.DataTextField  = "Lorry_No";
            ddlTruckNo.DataValueField = "Lorry_Idno";
            ddlTruckNo.DataBind();
            ddlTruckNo.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
        }
Пример #7
0
        public void Populate(Int32 intMatIdNo)
        {
            TyreIssueDAL obj        = new TyreIssueDAL();
            TyreIssHead  objMatHead = obj.SelectMatHead(intMatIdNo);
            var          objMatDetl = obj.SelectMatDetail(intMatIdNo);

            hidGRHeadIdno.Value = Convert.ToString(intMatIdNo);
            if (objMatHead != null)
            {
                ddlDateRange.SelectedValue = Convert.ToString(objMatHead.Year_Idno);
                txtGRDate.Text             = string.IsNullOrEmpty(Convert.ToString(objMatHead.MatIss_Date)) ? "" : Convert.ToDateTime(objMatHead.MatIss_Date).ToString("dd-MM-yyyy");
                iGrAgainst = Convert.ToInt32(objMatHead.MatIss_Typ);

                // RDbDirect.Enabled = false; RDbRecpt.Enabled = false;
                //new
                txtRemarkhead.Text = string.IsNullOrEmpty(Convert.ToString(objMatHead.ReMark)) ? "" : Convert.ToString(objMatHead.ReMark);

                txtGRNo.Text             = string.IsNullOrEmpty(Convert.ToString(objMatHead.MatIss_No)) ? "" : Convert.ToString(objMatHead.MatIss_No);
                ddlTruckNo.SelectedValue = string.IsNullOrEmpty(Convert.ToString(objMatHead.Truck_Idno)) ? "0" : Convert.ToString(objMatHead.Truck_Idno);
                ddlTruckNo_SelectedIndexChanged(null, null);
                ddlDriver.SelectedValue   = string.IsNullOrEmpty(Convert.ToString(objMatHead.Driver_Idno)) ? "0" : Convert.ToString(objMatHead.Driver_Idno);
                ddlReciver.SelectedValue  = string.IsNullOrEmpty(Convert.ToString(objMatHead.Driver_Idno)) ? "0" : Convert.ToString(objMatHead.Driver_Idno);
                ddlLocation.SelectedValue = string.IsNullOrEmpty(Convert.ToString(objMatHead.Loc_Idno)) ? "0" : Convert.ToString(objMatHead.Loc_Idno);



                dtTemp = CreateDt();
                for (int counter = 0; counter < objMatDetl.Count; counter++)
                {
                    string strItemName      = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Item_Name"));
                    string strItemNameId    = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Iteam_Idno"));
                    string strQty           = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Item_Qty"));
                    string strWeight        = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Item_Weght"));
                    string strRate          = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Item_Rate"));
                    string strAmount        = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Item_Amnt"));
                    string strDetail        = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "Remark"));
                    string strStckdetlNO    = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "SerialNo"));
                    string strStckdetl_Idno = Convert.ToString(DataBinder.Eval(objMatDetl[counter], "SerlDetl_id"));
                    ApplicationFunction.DatatableAddRow(dtTemp, counter + 1, strItemName, strItemNameId, strQty, strWeight, strRate, strAmount, strDetail, strStckdetlNO, strStckdetl_Idno);
                }
                ViewState["dt"] = dtTemp;
                BindGridT();
                txtNetAmnt.Text = string.IsNullOrEmpty(Convert.ToString(objMatHead.Net_Amnt)) ? "0" : String.Format("{0:0,0.00}", objMatHead.Net_Amnt);
                PrintMaterial(objMatHead, objMatDetl);
            }
            obj = null;
        }
Пример #8
0
        private void BindEmployee()
        {
            TyreIssueDAL objm = new TyreIssueDAL();
            var          EMPS = objm.SelectEmployee();

            ddlReciver.DataSource     = EMPS;
            ddlReciver.DataTextField  = "Acnt_Name";
            ddlReciver.DataValueField = "Acnt_Idno";
            ddlReciver.DataBind();
            ddlReciver.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));

            ddlDriver.DataSource     = EMPS;
            ddlDriver.DataTextField  = "Acnt_Name";
            ddlDriver.DataValueField = "Acnt_Idno";
            ddlDriver.DataBind();
            ddlDriver.Items.Insert(0, new System.Web.UI.WebControls.ListItem("--Select--", "0"));
            objm = null;
        }
        protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strMsg = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("TyreIssue.aspx?TyreIssue=" + e.CommandArgument, true);
            }
            if (e.CommandName == "cmddelete")
            {
                using (TransactionScope Tran = new TransactionScope(TransactionScopeOption.Required))
                {
                    TyreIssueDAL obj      = new TyreIssueDAL();
                    Int32        intValue = obj.Delete(Convert.ToInt32(e.CommandArgument));
                    obj = null;
                    if (intValue > 0)
                    {
                        this.BindGrid();
                        strMsg = "Record deleted successfully.";
                        Tran.Complete();
                        //txtGRNo.Focus();
                    }
                    else
                    {
                        if (intValue == -1)
                        {
                            strMsg = "Record can not be deleted. It is in use.";
                        }
                        else
                        {
                            strMsg = "Record not deleted.";
                        }
                        Tran.Dispose();
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
            }
        }
        private void BindGrid()
        {
            TyreIssueDAL obj      = new TyreIssueDAL();
            DateTime?    dtfrom   = null;
            DateTime?    dtto     = null;
            Int64        yearIDNO = Convert.ToInt32(ddlDateRange.SelectedValue);
            Int64        location = Convert.ToInt32(ddlLocation.SelectedValue);
            Int64        truckno  = Convert.ToInt32(ddlTruckNo.SelectedValue);

            if (string.IsNullOrEmpty(Convert.ToString(Datefrom.Text)) == false)
            {
                dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Datefrom.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(Datefrom.Text)) == false)
            {
                dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Dateto.Text));
            }
            Int32 yearidno    = Convert.ToInt32(ddlDateRange.SelectedValue == "" ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue));
            var   lstGridData = obj.SelectMatrial(dtfrom, dtto, location, truckno, yearidno);

            obj = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                grdMain.DataSource = lstGridData;
                grdMain.DataBind();
                lblTotalRecord.Text = "Total Record (s): " + lstGridData.Count;
                imgBtnExcel.Visible = false;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "Total Record (s): 0 ";
                imgBtnExcel.Visible = false;
            }
        }
Пример #11
0
        protected void imgBtnSave_Click(object sender, ImageClickEventArgs e)
        {
            #region fill values to Variables
            TyreIssueDAL objGrprepDAL = new TyreIssueDAL();
            dtTemp = (DataTable)ViewState["dt"];
            //AcntDS = objGrprepDAL.DtAcntDS(ApplicationFunction.ConnectionString());
            //DsTrAcnt = objGrprepDAL.DsTrAcnt(ApplicationFunction.ConnectionString());
            #endregion

            #region Validation Messages

            //if (ddlReciver.SelectedIndex == 0) { this.ShowMessageErr("Please select Receiver's Name."); ddlReciver.Focus(); lblmessage.Visible = true; lblmessage.Text = "* Please select Receiver's Name."; return; }
            if (ddlLocation.SelectedIndex == 0)
            {
                this.ShowMessageErr("Please select Delivery Place."); ddlLocation.Focus(); lblmessage.Visible = true; lblmessage.Text = "* Please select Delivery Place."; return;
            }
            if ((dtTemp != null) && (dtTemp.Rows.Count == 0))
            {
                this.ShowMessageErr("Please enter Item Details ."); return;
            }

            #endregion
            //txtGrNo=txtIssueNo
            #region Declare Input Variables
            string   strMsg          = string.Empty;
            Int64    intMaterialIdno = 0;
            DateTime strMatDate      = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtGRDate.Text.Trim().ToString()));
            DateTime dtMatDate       = strMatDate;
            Int32    IAgainst        = Convert.ToInt32(1);
            Int32    YearIdno        = Convert.ToInt32(ddlDateRange.SelectedValue) == -1 ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue);
            Int64    intMatNo        = string.IsNullOrEmpty(txtGRNo.Text.Trim()) ? 0 : Convert.ToInt64(txtGRNo.Text.Trim());
            Int32    TruckNoIdno     = string.IsNullOrEmpty(ddlTruckNo.SelectedValue) ? 0 : Convert.ToInt32(ddlTruckNo.SelectedValue);
            Int32    intIssueIDno    = string.IsNullOrEmpty(ddlReciver.SelectedValue) ? 0 : Convert.ToInt32(ddlReciver.SelectedValue);
            Int32    intLoc_Id       = string.IsNullOrEmpty(ddlLocation.SelectedValue) ? 0 : Convert.ToInt32(ddlLocation.SelectedValue);
            Int64    intDriver_Id    = string.IsNullOrEmpty(ddlDriver.SelectedValue) ? 0 : Convert.ToInt32(ddlDriver.SelectedValue);
            //new
            string    strRemarkhead = txtRemarkhead.Text.Trim();
            string    strNetAmnt    = (Convert.ToString(txtNetAmnt.Text)).Replace(",", "");
            Double    DNetAmnt      = string.IsNullOrEmpty(strNetAmnt) ? 0 : Convert.ToDouble(strNetAmnt);
            DataTable dtDetail      = (DataTable)ViewState["dt"];

            #endregion

            #region Insert/Update with Transaction
            using (TransactionScope tScope = new TransactionScope(TransactionScopeOption.Required))
            {
                if (grdMain.Rows.Count > 0 && dtTemp != null && dtTemp.Rows.Count > 0)
                {
                    TyreIssueDAL objMat     = new TyreIssueDAL();
                    string       Matfrom    = "BK";
                    Int64        MaxIssueNo = 0;
                    Int64        GrIdnos    = Convert.ToInt64(Convert.ToString(hidGRHeadIdno.Value) == "" ? 0 : Convert.ToInt64(hidGRHeadIdno.Value));
                    MaxIssueNo = objMat.MaxNo(Matfrom, Convert.ToInt32(ddlDateRange.SelectedValue), Convert.ToInt32(Convert.ToString(ddlLocation.SelectedValue) == "" ? 0 : Convert.ToInt32(ddlLocation.SelectedValue)), ApplicationFunction.ConnectionString());
                    if (Convert.ToString(hidGRHeadIdno.Value) == "")
                    {
                        if ((txtGRNo.Text.Trim() != "") && (Convert.ToInt64(txtGRNo.Text.Trim()) > 0))
                        {
                            var lst = objMat.CheckDuplicateGrNo(Convert.ToInt64(txtGRNo.Text.Trim()), Convert.ToInt64(Convert.ToString(ddlLocation.SelectedValue) == "" ? 0 : Convert.ToInt64(ddlLocation.SelectedValue)), Convert.ToInt64(ddlDateRange.SelectedValue));
                            if (lst.Count > 0)
                            {
                                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg1", "ShowConfirmAtSave()", true);
                                return;
                            }
                            //if ((txtGRNo.Text != Convert.ToString(MaxGRNo)) && (GrIdnos != Convert.ToInt32(txtGRNo.Text)))
                            //{
                            //    ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg1", "ShowConfirm()", true);
                            //}
                        }
                        else
                        {
                            this.ShowMessageErr("Issue No. can't be left blank.");
                            txtGRNo.Text = Convert.ToString(MaxIssueNo);
                            txtGRNo.Focus(); txtGRNo.SelectText();
                            return;
                        }
                    }
                    TyreIssueDAL obj = new TyreIssueDAL();
                    if (Convert.ToString(hidGRHeadIdno.Value) != "")
                    {
                        intMaterialIdno = obj.MatUpdate(Convert.ToInt64(hidGRHeadIdno.Value), dtMatDate, IAgainst, intMatNo, intLoc_Id, TruckNoIdno, DNetAmnt, YearIdno, dtDetail, intIssueIDno, strRemarkhead, intDriver_Id);
                    }
                    else
                    {
                        intMaterialIdno = obj.InsertMat(dtMatDate, IAgainst, intMatNo, intLoc_Id, TruckNoIdno, DNetAmnt, YearIdno, dtDetail, intIssueIDno, strRemarkhead, intDriver_Id);
                    }
                    obj = null;
                    if (intMaterialIdno > 0)
                    {
                        if (Convert.ToString(hidGRHeadIdno.Value) != null && Convert.ToString(hidGRHeadIdno.Value) != "")
                        {
                            this.ShowMessage("Record updated successfully.");
                        }
                        else
                        {
                            this.ShowMessage("Record saved successfully.");
                        }
                        //ddlLocation_SelectedIndexChanged(null, null);
                        //ddlFromCity_SelectedIndexChanged(null, null);
                        this.ClearAll();
                        ViewState["dt"] = dtTemp = null;
                        this.BindGridT();
                        ddlDateRange.Focus();
                        tScope.Complete();
                        //kapil
                        // Response.Redirect("MaterialIssue.aspx");
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(Convert.ToString(hidGRHeadIdno.Value)) == false)
                        {
                            hidpostingmsg.Value = "Record(s) not updated.";
                        }
                        else
                        {
                            hidpostingmsg.Value = "Record(s) not saved.";
                        }
                        tScope.Dispose();

                        //tScope.Dispose();
                        //ScriptManager.RegisterStartupScript(this, this.GetType(), "hwa", "PassMessageError('" + Convert.ToString(hidpostingmsg.Value) + "')", true);
                        //return;
                    }
                }

                else if (intMaterialIdno < 0)
                {
                    //this.ShowMessageErr("Entry already made with this GR. No.");
                    if (txtGRNo.Text != "")
                    {
                        //  checkGRNoAtSave = true;
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "alertmsg1", "ShowConfirmAtSave()", true);
                    }
                }
                else
                {
                    if (Convert.ToString(hidGRHeadIdno.Value) != null && Convert.ToString(hidGRHeadIdno.Value) != "")
                    {
                        this.ShowMessageErr("Record not updated.");
                    }
                    else
                    {
                        this.ShowMessageErr("Record not saved.");
                    }
                }
            }

            Int64        iMaxGRNo = 0;
            TyreIssueDAL objGRDAL = new TyreIssueDAL();
            iMaxGRNo = objGRDAL.MaxNo("BK", Convert.ToInt32(ddlDateRange.SelectedValue), Convert.ToInt32(Convert.ToString(ddlLocation.SelectedValue) == "" ? 0 :
                                                                                                         Convert.ToInt32(ddlLocation.SelectedValue)), ApplicationFunction.ConnectionString());

            txtGRNo.Text = Convert.ToString(iMaxGRNo);

            //ddlGRType.Focus();
            #endregion
        }