protected void grdMain_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strMsg = string.Empty;

            if (e.CommandName == "cmdedit")
            {
                Response.Redirect("MaterialIssue.aspx?MatIssue=" + e.CommandArgument, true);
            }
            if (e.CommandName == "cmddelete")
            {
                MaterialDAL obj      = new MaterialDAL();
                Int32       intValue = obj.Delete(Convert.ToInt32(e.CommandArgument));
                obj = null;
                if (intValue > 0)
                {
                    this.BindGrid();
                    strMsg = "Record deleted successfully.";
                    //txtGRNo.Focus();
                }
                else
                {
                    if (intValue == -1)
                    {
                        strMsg = "Record can not be deleted. It is in use.";
                    }
                    else
                    {
                        strMsg = "Record not deleted.";
                    }
                }
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alertstrMsg", "PassMessage('" + strMsg + "')", true);
            }
        }
Example #2
0
        //删除
        public override bool DeleteData()
        {
            try
            {
                if (XtraMessageBox.Show("是否删除选中的数据?", "友情提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    macls = new MaterialCls();

                    int[] rows = gridView1.GetSelectedRows();

                    for (int i = 0; i < rows.Length; i++)
                    {
                        macls = (MaterialCls)gridView1.GetRow(rows[i]);
                        MaterialDAL.DeleteMaterialById(macls.Id);
                    }
                }

                //QueryAll();

                init_cmbBox();

                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
Example #3
0
        public int Update(MaterialModel ObjModel, SqlTransaction Transaction)
        {
            MaterialDAL ldal = new MaterialDAL(Transaction);

            ObjModel.InputDate = DateTime.Now;
            return(ldal.Update(ObjModel));
        }
Example #4
0
 private string ImportSingle(string val)
 {
     try
     {
         string[] arr = ImportRule.SplitCsvLine(val);
         if (arr.Length < base.MinColCount)
         {
             return(string.Format("列不足{0}个", base.MinColCount));
         }
         string text = arr[1].Trim();
         if (text == "")
         {
             return("材料名称为空");
         }
         string text2 = arr[0].Trim();
         string text3 = "";
         if (text2 != "")
         {
             DataRow[] rowArray = this.m_tbSystemGroup.Select("FullName = '" + text2 + "'");
             if (rowArray.Length > 0)
             {
                 text3 = rowArray[0]["GroupCode"].ToString();
             }
         }
         if (text3 == "")
         {
             return(string.Format("未知的类型“{0}”", text2));
         }
         MaterialDAL   ldal = new MaterialDAL(this.conn);
         MaterialModel mObj = new MaterialModel();
         mObj.MaterialCode = int.Parse(SystemManageDAO.GetNewSysCode("MaterialCode"));
         mObj.MaterialName = text;
         mObj.GroupCode    = text3;
         mObj.Spec         = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 2)).Trim();
         mObj.Unit         = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 3)).Trim();
         mObj.InputPerson  = this.InputPerson;
         try
         {
             if (ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim() == "")
             {
                 mObj.StandardPrice = 0M;
             }
             else
             {
                 mObj.StandardPrice = decimal.Parse(ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim());
             }
         }
         catch
         {
             return(string.Format("参考价“{0}”不是有效的数值", ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 4)).Trim()));
         }
         mObj.Remark = ConvertRule.ToString(ConvertRule.GetArrayItem(arr, 5)).Trim();
         ldal.Insert(mObj);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     return("");
 }
Example #5
0
        public int Delete(int Code, SqlTransaction Transaction)
        {
            MaterialDAL ldal = new MaterialDAL(Transaction);

            this.CheckBeforeDelete(Code, Transaction);
            return(ldal.Delete(Code));
        }
        protected void grdMain_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            double dblChallanAmnt = 0;

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                dblChallanAmnt  = Convert.ToDouble(DataBinder.Eval(e.Row.DataItem, "Net_Amnt"));
                dblTChallanAmnt = dblChallanAmnt + dblTChallanAmnt;
                MaterialDAL obj          = new MaterialDAL();
                LinkButton  lnkbtnDelete = (LinkButton)e.Row.FindControl("lnkbtnDelete");
                var         Result       = obj.CheckForDelete(Convert.ToInt64(DataBinder.Eval(e.Row.DataItem, "MatIss_Idno")));
                if (Result != null)
                {
                    lnkbtnDelete.Visible = false;
                }
                else
                {
                    lnkbtnDelete.Visible = true;
                }
            }
            else if (e.Row.RowType == DataControlRowType.Footer)
            {
                Label lblTChallanAmnt = (Label)e.Row.FindControl("lblGridtotalnet");
                lblTChallanAmnt.Text = dblTChallanAmnt.ToString("N2");
            }
        }
        private void BindTruckNo()
        {
            MaterialDAL objTruck   = new MaterialDAL();
            var         TruckNolst = objTruck.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"));
        }
        private void BindItemName()
        {
            MaterialDAL objTruck = new MaterialDAL();
            var         itemname = objTruck.BindItemName();

            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"));
        }
        private void BindDriverName()
        {
            MaterialDAL objm = new MaterialDAL();
            var         EMPS = objm.SelectEmployee();

            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;
        }
        private void BindGrid()
        {
            MaterialDAL obj      = new MaterialDAL();
            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(Dateto.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 = "T. Record (s): " + lstGridData.Count;
                Double TotalNetAmount = 0;
                for (int i = 0; i < lstGridData.Count; i++)
                {
                    TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt"));
                }
                lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");

                imgBtnExcel.Visible = false;
                int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                lblcontant.Text    = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString();
                lblcontant.Visible = true;
                divpaging.Visible  = true;
                prints.Visible     = false;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): 0 ";
                imgBtnExcel.Visible = false;
                lblcontant.Visible  = false;
                divpaging.Visible   = false;
                prints.Visible      = false;
            }
        }
        protected void lnkTruckRefresh_Click(object sender, EventArgs e)
        {
            MaterialDAL objTruck   = new MaterialDAL();
            var         TruckNolst = objTruck.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"));

            lnkTruckRefresh.Focus();
        }
        public void countall()
        {
            MaterialDAL obj   = new MaterialDAL();
            Int64       count = 0;

            count = obj.CountAll();
            if (count > 0)
            {
                lblTotalRecord.Text = "T. Record (s):" + count;
            }
            else
            {
                lblTotalRecord.Text = "Total Record (s): 0 ";
            }
        }
Example #13
0
        //查询所有
        public override bool QueryAll()
        {
            try
            {
                maList = new List <MaterialCls>();

                maList = MaterialDAL.GetAll();

                MaterialBindingSource.DataSource = maList;
                this.gridControl1.DataSource     = MaterialBindingSource;

                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
Example #14
0
        public override bool RefreshData()
        {
            try
            {
                string UserName = this.ItemObjectList.EditValue.ToString();

                MaterialCls val = MaterialDAL.QueryMaterialByName(UserName);

                MaterialBindingSource.DataSource = val;

                gridControl1.DataSource = MaterialBindingSource;

                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
Example #15
0
        //下拉框初始化
        public bool init_cmbBox()
        {
            try
            {
                this.cmbObjectList.Items.Clear();
                maList = new List <MaterialCls>();
                maList = MaterialDAL.GetAll();

                foreach (var val in maList)
                {
                    this.cmbObjectList.Items.Add(val.MaterialName);
                }

                return(true);;
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
Example #16
0
        public MaterialBL()
        {
            var conn = new SqlConnection();

            _materialDAL = new MaterialDAL(conn);
        }
Example #17
0
        public List <MaterialModel> GetModels(SqlTransaction Transaction)
        {
            MaterialDAL ldal = new MaterialDAL(Transaction);

            return(ldal.Select());
        }
Example #18
0
        public List <MaterialModel> GetModels(MaterialQueryModel ObjQueryModel, SqlTransaction Transaction)
        {
            MaterialDAL ldal = new MaterialDAL(Transaction);

            return(ldal.Select(ObjQueryModel));
        }
Example #19
0
        public MaterialModel GetModel(object Code, SqlConnection Connection)
        {
            MaterialDAL ldal = new MaterialDAL(Connection);

            return(ldal.GetModel(Code));
        }
Example #20
0
        public List <MaterialModel> GetModels(SqlConnection Connection)
        {
            MaterialDAL ldal = new MaterialDAL(Connection);

            return(ldal.Select());
        }
Example #21
0
        public MaterialModel GetModel(int Code, SqlTransaction Transaction)
        {
            MaterialDAL ldal = new MaterialDAL(Transaction);

            return(ldal.GetModel(Code));
        }
Example #22
0
        //保存
        public override bool SaveDataA()
        {
            try
            {
                if (AddorModify == AddOrModifyEnum.Add)
                {
                    macls = new MaterialCls();

                    macls.MaterialName              = this.txtMaterialName.Text.ToString();
                    macls.ElasticModulus            = Convert.ToDouble(this.txtElasticModulus.Text.ToString());
                    macls.TensileStrength           = Convert.ToDouble(this.txtTensileStrength.Text.ToString());
                    macls.YieldSrength              = Convert.ToDouble(this.txtYieldSrength.Text.ToString());
                    macls.UltimateElongation        = Convert.ToDouble(this.txtUltimateElongation.Text.ToString());
                    macls.ReductionOfArea           = Convert.ToDouble(this.txtReductionOfArea.Text.ToString());
                    macls.HardenablityValue         = Convert.ToDouble(this.txtHardenablityValue.Text.ToString());
                    macls.StrainOfWidthAndThickness = Convert.ToDouble(this.txtStrainOfWidthAndThickness.Text.ToString());

                    int re = MaterialDAL.AddMaterial(macls);

                    if (re > 0)
                    {
                        MaterialBindingSource.DataSource = macls;
                        this.gridControl1.DataSource     = MaterialBindingSource;

                        this.layoutControlGroup1.Enabled = false;

                        this.txtMaterialName.Text              = "";
                        this.txtElasticModulus.Text            = "";
                        this.txtTensileStrength.Text           = "";
                        this.txtYieldSrength.Text              = "";
                        this.txtUltimateElongation.Text        = "";
                        this.txtReductionOfArea.Text           = "";
                        this.txtHardenablityValue.Text         = "";
                        this.txtStrainOfWidthAndThickness.Text = "";

                        init_cmbBox();

                        MessageBox.Show("材料信息增加成功!");

                        return(true);
                    }
                    else
                    {
                        MessageBox.Show("材料信息增加失败!");

                        return(false);
                    }
                }
                else if (AddorModify == AddOrModifyEnum.Modify)
                {
                    macls.MaterialName              = this.txtMaterialName.Text.ToString();
                    macls.ElasticModulus            = Convert.ToDouble(this.txtElasticModulus.Text.ToString());
                    macls.TensileStrength           = Convert.ToDouble(this.txtTensileStrength.Text.ToString());
                    macls.YieldSrength              = Convert.ToDouble(this.txtYieldSrength.Text.ToString());
                    macls.UltimateElongation        = Convert.ToDouble(this.txtUltimateElongation.Text.ToString());
                    macls.ReductionOfArea           = Convert.ToDouble(this.txtReductionOfArea.Text.ToString());
                    macls.HardenablityValue         = Convert.ToDouble(this.txtHardenablityValue.Text.ToString());
                    macls.StrainOfWidthAndThickness = Convert.ToDouble(this.txtStrainOfWidthAndThickness.Text.ToString());

                    MaterialDAL.ModifyMaterialByid(macls);

                    this.layoutControlGroup1.Enabled = false;

                    init_cmbBox();


                    return(true);
                }
                else
                {
                    MessageBox.Show("材料信息添加/修改失败!");
                    return(false);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("材料信息添加失败:{0}!", ex.Message.ToString());
                return(false);
            }
        }
Example #23
0
 public MaterialBLL()
 {
     db = new MaterialDAL();
 }
Example #24
0
 public MaterialBAL()
 {
     materialDAL = new MaterialDAL();
 }
        private void BindGrid()
        {
            MaterialDAL obj        = new MaterialDAL();
            DateTime?   dtfrom     = null;
            DateTime?   dtto       = null;
            Int64       location   = Convert.ToInt32(ddlLocation.SelectedValue);
            Int64       truckno    = Convert.ToInt32(ddlTruckNo.SelectedValue);
            Int64       ItemIdno   = Convert.ToInt64(ddlItemName.SelectedValue);
            Int64       DriverIdno = Convert.ToInt64(ddlDriver.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));


            if (ddlReportType.SelectedValue == "1")
            {
                var lstGridData = obj.SelectMatrialIssueReportSummary(dtfrom, dtto, location, truckno, yearidno, DriverIdno, ItemIdno);
                if (lstGridData != null && lstGridData.Count > 0)
                {
                    grdMain.DataSource = lstGridData;
                    grdMain.DataBind();
                    lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;
                    imgBtnExcel.Visible = true;

                    DataTable dt = new DataTable();
                    dt.Columns.Add("SrNo", typeof(string));
                    dt.Columns.Add("MatIss_No", typeof(string));
                    dt.Columns.Add("MatIss_Date", typeof(string));
                    dt.Columns.Add("CityTo", typeof(string));
                    dt.Columns.Add("Item_Name", typeof(string));
                    dt.Columns.Add("Item_Qty", typeof(string));
                    dt.Columns.Add("Acnt_Name", typeof(string));
                    dt.Columns.Add("Lorry_No", typeof(string));
                    dt.Columns.Add("Item_Amnt", typeof(string));
                    dt.Columns.Add("Align", typeof(string));
                    dt.Columns.Add("Prev_AlignDate", typeof(string));
                    dt.Columns.Add("AlignDate", typeof(string));

                    for (int i = 0; i < lstGridData.Count; i++)
                    {
                        DataRow dr = dt.NewRow();
                        dr["SrNo"]           = Convert.ToString(i + 1);
                        dr["MatIss_No"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "MatIss_No"));
                        dr["MatIss_Date"]    = Convert.ToDateTime(DataBinder.Eval(lstGridData[i], "MatIss_Date")).ToString("dd-MM-yyyy");
                        dr["CityTo"]         = Convert.ToString(DataBinder.Eval(lstGridData[i], "CityTo"));
                        dr["Item_Name"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "Item_Name"));
                        dr["Item_Qty"]       = Convert.ToString(DataBinder.Eval(lstGridData[i], "Qty"));
                        dr["Acnt_Name"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "Acnt_Name"));
                        dr["Lorry_No"]       = Convert.ToString(DataBinder.Eval(lstGridData[i], "Lorry_No"));
                        dr["Item_Amnt"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "Item_Amnt"));
                        dr["Align"]          = Convert.ToString(DataBinder.Eval(lstGridData[i], "Align"));
                        dr["Prev_AlignDate"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Prev_AlignDate"));
                        dr["AlignDate"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "AlignDate"));
                        dt.Rows.Add(dr);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        ViewState["Dt"] = dt;
                    }
                }
                else
                {
                    grdMain.DataSource = null;
                    grdMain.DataBind();
                    lblTotalRecord.Text = "T. Record (s): 0 ";
                    imgBtnExcel.Visible = false;
                    lblcontant.Visible  = false;
                    divpaging.Visible   = false;
                }
            }
            else
            {
                var lstGridData = obj.SelectMatrialIssueReport(dtfrom, dtto, location, truckno, yearidno, DriverIdno, ItemIdno);
                if (lstGridData != null && lstGridData.Count > 0)
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add("SrNo", typeof(string));
                    dt.Columns.Add("MatIss_No", typeof(string));
                    dt.Columns.Add("MatIss_Date", typeof(string));
                    dt.Columns.Add("CityTo", typeof(string));
                    dt.Columns.Add("Item_Name", typeof(string));
                    dt.Columns.Add("Item_Qty", typeof(string));
                    dt.Columns.Add("Acnt_Name", typeof(string));
                    dt.Columns.Add("Lorry_No", typeof(string));
                    dt.Columns.Add("Item_Amnt", typeof(string));
                    dt.Columns.Add("Align", typeof(string));
                    dt.Columns.Add("Prev_AlignDate", typeof(string));
                    dt.Columns.Add("AlignDate", typeof(string));

                    for (int i = 0; i < lstGridData.Count; i++)
                    {
                        DataRow dr = dt.NewRow();
                        dr["SrNo"]           = Convert.ToString(i + 1);
                        dr["MatIss_No"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "MatIss_No"));
                        dr["MatIss_Date"]    = Convert.ToDateTime(DataBinder.Eval(lstGridData[i], "MatIss_Date")).ToString("dd-MM-yyyy");
                        dr["CityTo"]         = Convert.ToString(DataBinder.Eval(lstGridData[i], "CityTo"));
                        dr["Item_Name"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "Item_Name"));
                        dr["Item_Qty"]       = Convert.ToString(DataBinder.Eval(lstGridData[i], "Qty"));
                        dr["Acnt_Name"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "Acnt_Name"));
                        dr["Lorry_No"]       = Convert.ToString(DataBinder.Eval(lstGridData[i], "Lorry_No"));
                        dr["Item_Amnt"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "Item_Amnt"));
                        dr["Align"]          = Convert.ToString(DataBinder.Eval(lstGridData[i], "Align"));
                        dr["Prev_AlignDate"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Prev_AlignDate"));
                        dr["AlignDate"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "AlignDate"));
                        dt.Rows.Add(dr);
                    }
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        ViewState["Dt"] = dt;
                    }

                    Double TotalNetAmount = 0;

                    for (int i = 0; i < lstGridData.Count; i++)
                    {
                        TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Item_Amnt"));
                    }
                    lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");

                    grdMain.DataSource = lstGridData;
                    grdMain.DataBind();
                    lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;
                    imgBtnExcel.Visible = true;

                    int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                    int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                    lblcontant.Text    = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString();
                    lblcontant.Visible = true;
                    divpaging.Visible  = true;
                }
                else
                {
                    grdMain.DataSource = null;
                    grdMain.DataBind();
                    lblTotalRecord.Text = "T. Record (s): 0 ";
                    imgBtnExcel.Visible = false;
                    lblcontant.Visible  = false;
                    divpaging.Visible   = false;
                }
            }
            obj = null;
        }