Exemple #1
0
 private void btnSaveNew_Click(object sender, EventArgs e)
 {
     if (saveData())
     {
         model = new ProductCheckForceModel();
         loadData();
     }
 }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (ID == 0)
            {
                return;
            }
            ProductCheckForceModel model = ProductCheckForceBO.Instance.FindByPK(ID) as ProductCheckForceModel;

            if (model == null)
            {
                return;
            }
            string ProductCode = TextUtils.ToString(grvData.GetFocusedRowCellValue(colProductCode));

            if (string.IsNullOrEmpty(ProductCode.Trim()))
            {
                return;
            }
            Expression expression = new Expression("ProductCode", ProductCode);
            ArrayList  arrProduct = ProductBO.Instance.FindByExpression(expression);

            if (arrProduct.Count == 0)
            {
                return;
            }
            ProductModel        product = arrProduct[0] as ProductModel;
            frmCheckForceDetail frm     = new frmCheckForceDetail();

            frm.model = model;
            if (frm.ShowDialog() == DialogResult.OK)
            {
                LoadInfoSearch();
            }
        }
Exemple #3
0
 protected ProductCheckForceFacade(ProductCheckForceModel model) : base(model)
 {
 }
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            int rowCount = grvData.RowCount;
            int colCount = grvData.Columns.Count;
            ProductCheckForceModel model = new ProductCheckForceModel();

            for (int i = 0; i < rowCount; i++)
            {
                try
                {
                    progressBar1.Invoke((Action)(() => { progressBar1.Value = i + 1; }));
                    txtRate.Invoke((Action)(() => { txtRate.Text = string.Format("{0}/{1}", i + 1, rowCount); }));

                    // update CheckForce
                    if (string.IsNullOrEmpty(grvData.GetRowCellValue(i, "F1").ToString().Trim()) || string.IsNullOrEmpty(grvData.GetRowCellValue(i, "F11").ToString().Trim()))
                    {
                        continue;
                    }
                    Expression expression = new Expression("ProductCode", Lib.ToString(grvData.GetRowCellValue(i, "F1")));
                    ArrayList  lst        = ProductBO.Instance.FindByExpression(expression);
                    if (lst.Count <= 0)
                    {
                        continue;
                    }
                    string sql = string.Format("Select ID from ProductCheckForce Where ProductCode = '{0}' And ProductStepCode = '{1}'",
                                               Lib.ToString(grvData.GetRowCellValue(i, "F1")), Lib.ToString(grvData.GetRowCellValue(i, "F12")));
                    SqlDataReader reader = SqlHelper.ExecuteReader(DBUtils.GetDBConnectionString(), CommandType.Text, sql);
                    if (reader.Read())
                    {
                        model = ProductCheckForceBO.Instance.FindByPK(long.Parse(reader[0].ToString())) as ProductCheckForceModel;
                        string[] CheckForce = Lib.ToString(grvData.GetRowCellValue(i, "F4")).Split('~');
                        model.CheckForceMin = TextUtils.ToDecimal(CheckForce[0]);
                        model.CheckForceMax = TextUtils.ToDecimal(CheckForce[1]);
                        model.GunNumber     = Lib.ToInt(grvData.GetRowCellValue(i, "F5"));
                        model.JobNumber     = Lib.ToInt(grvData.GetRowCellValue(i, "F6"));
                        model.QtyBuLong     = Lib.ToInt(grvData.GetRowCellValue(i, "F7"));
                        model.ShootNumber   = Lib.ToInt(grvData.GetRowCellValue(i, "F8"));
                        model.QtyOcBanGa    = Lib.ToInt(grvData.GetRowCellValue(i, "F9"));
                        model.QtyOcBanThat  = Lib.ToInt(grvData.GetRowCellValue(i, "F10"));
                        model.SetForce      = Lib.ToDecimal(grvData.GetRowCellValue(i, "F11"));
                        ProductCheckForceBO.Instance.Update(model);
                    }
                    else
                    {
                        model.ProductCode = Lib.ToString(grvData.GetRowCellValue(i, "F1"));
                        string[] CheckForce = Lib.ToString(grvData.GetRowCellValue(i, "F4")).Split('~');
                        model.CheckForceMin   = TextUtils.ToDecimal(CheckForce[0]);
                        model.CheckForceMax   = TextUtils.ToDecimal(CheckForce[1]);
                        model.GunNumber       = Lib.ToInt(grvData.GetRowCellValue(i, "F5"));
                        model.JobNumber       = Lib.ToInt(grvData.GetRowCellValue(i, "F6"));
                        model.QtyBuLong       = Lib.ToInt(grvData.GetRowCellValue(i, "F7"));
                        model.ShootNumber     = Lib.ToInt(grvData.GetRowCellValue(i, "F8"));
                        model.QtyOcBanGa      = Lib.ToInt(grvData.GetRowCellValue(i, "F9"));
                        model.QtyOcBanThat    = Lib.ToInt(grvData.GetRowCellValue(i, "F10"));
                        model.SetForce        = Lib.ToDecimal(grvData.GetRowCellValue(i, "F11"));
                        model.ProductStepCode = Lib.ToString(grvData.GetRowCellValue(i, "F12"));
                        ProductCheckForceBO.Instance.Insert(model);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(i.ToString() + Environment.NewLine + ex.ToString());
                }
            }
        }