コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Please Wait...", "Processing Data"))
                {
                    ProductGroup.ProductGroupCode = txtCode.Text.Trim();
                    ProductGroup.ProductGroupName = txtName.Text.Trim();
                    if (ProductGroup.ID <= 0)
                    {
                        ProductGroup.ID = (int)ProductGroupBO.Instance.Insert(ProductGroup);
                    }
                    else
                    {
                        ProductGroupBO.Instance.Update(ProductGroup);
                    }
                    CurentNode = ProductGroup.ID;
                    for (int i = 0; i < arrStep.Count; i++)
                    {
                        _STT  = Lib.ToInt(grvData.GetRowCellValue(i, colSortOrder));
                        _Name = Lib.ToString(grvData.GetRowCellValue(i, colName));
                        _Des  = Lib.ToString(grvData.GetRowCellValue(i, colDes));
                        WorkingStepModel step = (WorkingStepModel)arrStep[i];
                        int type = 0;
                        if (step.ID <= 0)
                        {
                            step.ProductGroupID = ProductGroup.ID;
                            step.ID             = (int)WorkingStepBO.Instance.Insert(step);
                            type = 1;
                            //Thêm step vào các sản phẩm thuộc nhóm này
                        }
                        else
                        {
                            //string sql= $"SELECT TOP 1 ws.ID FROM dbo.WorkingStep ws JOIN dbo.ProductStep ps ON ws.ID = ps.WorkingStepID WHERE WorkingStepID = {step.ID} and ws.WorkingStepCode = N'{_Name}'  and ws.Description = N'{_Des}' and ws.SortOrder ='{_STT}'";
                            //int id = Lib.ToInt(LibIE.ExcuteScalar(sql));
                            //if (id == 0)
                            //{
                            WorkingStepBO.Instance.Update(step);
                            type = 2;
                            // type = 1;
                            //Cập nhật vào các sản phẩm thuộc nhóm này
                            //}
                        }

                        LibIE.ExcuteProcedure("spUpdateProductStep_ByWorkingStep"
                                              , new string[] { "@WorkingStepID", "@Type" }
                                              , new object[] { step.ID, type });
                    }

                    DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string    ProductGroup    = Lib.ToString(grvData.GetFocusedRowCellValue(colProductGroupCode));
            DataTable dt              = LibIE.Select($"SELECT DISTINCT ProductTypeCode FROM dbo.ConfigFormula WHERE ProductGroupCode='{ProductGroup}'");
            string    ProductTypeCode = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ProductTypeCode = Lib.ToString(dt.Rows[i]["ProductTypeCode"]);
                LibIE.ExcuteProcedure("spGetInsertFormula", new string[] { "@ProductTypeCode", "@ProductGroupCode" }, new object[] { ProductTypeCode, ProductGroup });
            }
        }
コード例 #3
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            txtRate.Text = "";

            int rowCount = grvData.RowCount;

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

                    string   ShipTo = Lib.ToString(grvData.GetRowCellValue(i, "F1"));                   // Đích
                    DateTime DeliveryDate;
                    DateTime AssemblyDate;
                    //Kiểm tra nếu đích trống thì next
                    if (string.IsNullOrEmpty(ShipTo))
                    {
                        continue;
                    }

                    DeliveryDate = Lib.ToDate3(grvData.GetRowCellValue(i, "F2"));                     // Ngày xuất hàng
                    if (Lib.ToDate3(grvData.GetRowCellValue(i, "F2")) == new DateTime(1950, 1, 1))
                    {
                        DeliveryDate = Lib.ToDate3(grvData.GetRowCellValue(i, "DATEF2"));
                    }

                    AssemblyDate = Lib.ToDate3(grvData.GetRowCellValue(i, "F3"));                    //Ngày lắp ráp
                    if (Lib.ToDate3(grvData.GetRowCellValue(i, "F3")) == new DateTime(1950, 1, 1))
                    {
                        AssemblyDate = Lib.ToDate3(grvData.GetRowCellValue(i, "DATEF3"));
                    }

                    LibIE.ExcuteProcedure("spUpdateAssemblyDate", new string[] { "@ShipTo", "@DeliveryDate", "@AssemblyDate" }, new object[] { ShipTo, DeliveryDate, AssemblyDate });
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Lỗi lưu dữ liệu tại dòng " + i + Environment.NewLine + ex.ToString());
                }
            }
        }
コード例 #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (grvData.FocusedRowHandle < 0)
            {
                return;
            }

            int strID = TextUtils.ToInt(grvData.GetFocusedRowCellValue("ID"));

            string strName = TextUtils.ToString(grvData.GetFocusedRowCellValue("SortOrder"));

            if (WorkingBO.Instance.CheckExist("WorkingStepID", strID))
            {
                MessageBox.Show("Công đoạn này đang được sử dụng bên Mục kiểm tra nên không thể xóa được!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (MessageBox.Show(String.Format("Bạn có chắc muốn xóa công đoạn [{0}] không?", strName), TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    if (strID > 0)
                    {
                        LibIE.ExcuteProcedure("spUpdateProductStep_ByWorkingStep"
                                              , new string[] { "@WorkingStepID", "@Type" }
                                              , new object[] { strID, 3 });
                    }

                    grvData.DeleteSelectedRows();
                }
                catch
                {
                    MessageBox.Show("Có lỗi xảy ra khi thực hiện thao tác, xin vui lòng thử lại sau.");
                }
            }
        }