コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int id = TextUtils.ToInt(grvDetail.GetFocusedRowCellValue(colWorkingID));
                if (id == 0)
                {
                    return;
                }

                if (MessageBox.Show("Bạn có chắc muốn xóa mục cần kiểm tra [" + grvDetail.GetFocusedRowCellValue(colWorkingName).ToString() + "] không?",
                                    TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
                WorkingBO.Instance.Delete(id);
                grvDetail.DeleteSelectedRows();
                //Xóa các thằng con thuộc thằng cha này đi
                LibIE.ExcuteSQL(string.Format("EXEC spUpdateMultiProductWorking {0}, 2", id));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: frmProductH.cs プロジェクト: Dung12345678/Dao
 private void btnUpdateStepCode_Click(object sender, EventArgs e)
 {
     using (WaitDialogForm fWait = new WaitDialogForm("", ""))
     {
         LibIE.ExcuteSQL("exec spReUpdateProductWorkingStepCode");
     }
 }
コード例 #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (treeData.DataSource == null)
            {
                return;
            }
            int id = (int)treeData.Selection[0].GetValue(colIDTree);

            if (id == 0)
            {
                return;
            }
            int pkKMP = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (MessageBox.Show("Bạn có chắc muốn xóa chi phí [" + TextUtils.ToInt(grvData.GetFocusedRowCellValue(colLinkName)) + "] ra khỏi nhóm không?",
                                TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }
            string sql = "update [T_DM_KMP] set [FK_GROUP] = 0 where [PK_ID] = " + pkKMP;

            LibIE.ExcuteSQL(sql);
            MessageBox.Show("Khoản mục phí ra khỏi nhóm thành công.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            loadLink();
        }
コード例 #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (treeData.DataSource == null)
            {
                return;
            }
            int id = TextUtils.ToInt(treeData.Selection[0].GetValue(colIDTree));

            if (id == 0)
            {
                return;
            }
            int count = 0;

            foreach (int i in grvData.GetSelectedRows())
            {
                int    pkKMP = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                string sql   = "update [T_DM_KMP] set [FK_GROUP] = " + id + " where [PK_ID] = " + pkKMP;
                LibIE.ExcuteSQL(sql);
                count++;
            }
            if (count > 0)
            {
                //MessageBox.Show("Thêm khoản mục phí vào nhóm thành công.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                loadLink();
            }
        }
コード例 #5
0
        private void btnCopy_Click(object sender, EventArgs e)
        {

            string GroupIDNew = TextUtils.ToString(Check.ValueMember);
            string[] arrListStr = GroupIDNew.Split(',');
            for (int i = 0; i < arrListStr.Length; i++)
            {
                LibIE.ExcuteSQL(string.Format($"EXEC spCopyALLGroupProducts @GroupID={GroupID}, @GroupNewID={arrListStr[i]}")); 
            }
        }
コード例 #6
0
ファイル: frmCopyStepH.cs プロジェクト: Dung12345678/Dao
        private void btnCopy_Click(object sender, EventArgs e)
        {
            int count = Check.CheckedItems.Count;//.CheckedItemsCount;

            for (int i = 0; i < count; i++)
            {
                int productGroupID = TextUtils.ToInt(Check.CheckedItems[i]);
                LibIE.ExcuteSQL(string.Format($"EXEC spCopyWorkingStepToOtherProductGroupH 	@WorkingStepDescription=N'{StepName}' ,@WorkingStepSortOrder={SortOrder} ,@WorkingStepCode=N'{StepCode}' ,@WorkingStepID={WorkingStepID} ,@ProductGroupID={productGroupID} "));
            }
            MessageBox.Show("Copy OK!");
            this.Close();
        }
コード例 #7
0
        //pb053153

        private void btnSave_Click(object sender, EventArgs e)
        {
            grvDetail.FocusedRowHandle = -1;
            for (int i = 0; i < grvDetail.RowCount; i++)
            {
                int id = TextUtils.ToInt(grvDetail.GetRowCellValue(i, colWorkingID));
                if (id == 0)
                {
                    continue;
                }
                string  value     = TextUtils.ToString(grvDetail.GetRowCellValue(i, colValue));
                decimal min       = TextUtils.ToDecimal(grvDetail.GetRowCellValue(i, colMin));
                decimal max       = TextUtils.ToDecimal(grvDetail.GetRowCellValue(i, colMax));
                string  updateSql = string.Format(@"UPDATE dbo.ProductWorking SET PeriodValue = '{0}' , MinValue = {1}, MaxValue = {2}                                     
                                        WHERE ID = {3}", value, min, max, id);
                LibIE.ExcuteSQL(updateSql);
            }
            //MessageBox.Show("Cất dữ liệu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //loadWorking();
        }
コード例 #8
0
ファイル: frmFCMmanagement.cs プロジェクト: B06-0253/NVTHAO
        private void btnDel_Click(object sender, EventArgs e)
        {
            _rownIndex = grvData.FocusedRowHandle;
            int id = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));

            if (id == 0)
            {
                return;
            }
            if (MessageBox.Show("Bạn có chắc muốn xóa FCM này không?",
                                TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
            {
                return;
            }

            T_DM_FCMBO.Instance.Delete(id);
            LibIE.ExcuteSQL("delete T_DM_FCM_DETAIL where FK_FCM = " + id);

            loadData();
        }
コード例 #9
0
        private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            //txtRate.Text = "";

            DataTable        dtGroup    = LibIE.Select("SELECT ID,ProductGroupCode FROM dbo.ProductGroup");
            List <BaseModel> lstProduct = ProductBO.Instance.GetAllListObject();

            int rowCount = grvData.RowCount;

            List <string> lstError = new List <string>();
            char          spt      = '~';

            for (int i = 0; i < rowCount; i++)
            {
                try
                {
                    if (i < 3)
                    {
                        continue;
                    }
                    progressBar1.Invoke((Action)(() => { progressBar1.Value = i - 2; }));
                    txtRate.Invoke((Action)(() => { txtRate.Text = string.Format("{0}/{1}", i - 2, rowCount - 3); }));
                    string productCode = Lib.ToString(grvData.GetRowCellValue(i, "F1"));                   // Product ID
                    string groupCode   = Lib.ToString(grvData.GetRowCellValue(i, "F2"));                   // Nhóm sản phẩm
                    //Kiểm tra nếu mã nhóm hoặc mã sản phẩm trống thì next
                    if (string.IsNullOrEmpty(groupCode) || string.IsNullOrEmpty(productCode))
                    {
                        continue;
                    }

                    DataRow[] arrG    = dtGroup.Select(string.Format("ProductGroupCode = '{0}'", groupCode));
                    int       groupID = 0;
                    if (arrG.Length > 0)
                    {
                        groupID = Lib.ToInt(arrG[0]["ID"]);
                    }
                    else
                    {
                        continue;
                    }
                    ProductModel product   = new ProductModel();
                    var          lstObject = lstProduct.FirstOrDefault(o => ((ProductModel)o).ProductCode.Trim().ToLower() == productCode.Trim().ToLower());
                    //ArrayList arrP = ProductBO.Instance.FindByAttribute("ProductCode", productCode);
                    int OldGroupID = 0;
                    if (lstObject != null)
                    {
                        product    = (ProductModel)lstObject;
                        OldGroupID = product.ProductGroupID;
                        if (OldGroupID != groupID)
                        {
                            ProductWorkingBO.Instance.DeleteByAttribute("ProductID", product.ID);
                            ProductStepBO.Instance.DeleteByAttribute("ProductID", product.ID);
                            ProductBO.Instance.Delete(product.ID);
                            product.ID = 0;
                        }
                    }

                    #region SetValue
                    string valueString = "";
                    product.ProductGroupID   = groupID;
                    product.ProductGroupCode = groupCode;
                    product.ProductCode      = productCode;
                    product.ProductName      = Lib.ToString(grvData.GetRowCellValue(i, "F3"));             //Mô tả-sản phẩm
                    product.ProductTypeCode  = Lib.ToString(grvData.GetRowCellValue(i, "F4"));             //Loại sản phẩm
                    product.RatioCode        = Lib.ToString(grvData.GetRowCellValue(i, "F5"));             //Ratio giảm tốc

                    product.ProductDate = Lib.ToDate3(grvData.GetRowCellValue(i, "F6"));                   //ngày lập
                    if (Lib.ToDate3(grvData.GetRowCellValue(i, "F6")) == new DateTime(1950, 1, 1))
                    {
                        product.ProductDate = Lib.ToDate2(grvData.GetRowCellValue(i, "DATEF6").ToString());
                    }

                    product.XuatLucSealCap = Lib.ToString(grvData.GetRowCellValue(i, "F7"));                  //Hướng trục xuất lực
                    product.LoaiMoNapDau   = Lib.ToString(grvData.GetRowCellValue(i, "F8"));                  // loại mỡ nắp dầu

                    product.LoaiMoBomHopSo = Lib.ToString(grvData.GetRowCellValue(i, "F10"));                 // loại mỡ bơm hộp số

                    product.LucCheckGear    = valueString = Lib.ToString(grvData.GetRowCellValue(i, "F37"));
                    product.LucCheckGearMin = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[0] : "0"); //Lực check gear Unit
                    product.LucCheckGearMax = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[1] : "0"); //Lực check gear Unit

                    product.GunNumber    = Lib.ToInt(grvData.GetRowCellValue(i, "F38"));                                  //Súng
                    product.JobNumber    = Lib.ToInt(grvData.GetRowCellValue(i, "F39"));                                  //JOB
                    product.BuLongNumber = Lib.ToInt(grvData.GetRowCellValue(i, "F40"));                                  //SỐ LUỢNG BULONG
                    product.ShootNumber  = Lib.ToInt(grvData.GetRowCellValue(i, "F41"));                                  //SỐ LẦN BẮN
                    product.QtyOcBanGa   = Lib.ToInt(grvData.GetRowCellValue(i, "F42"));                                  //BẮN GÁ
                    product.QtyOcBanThat = product.SetForce = Lib.ToInt(grvData.GetRowCellValue(i, "F43"));               //ĐẶT LỰC



                    product.MotorCode    = Lib.ToString(grvData.GetRowCellValue(i, "F53"));                            //MÃ MOTOR
                    product.CoilCode     = Lib.ToString(grvData.GetRowCellValue(i, "F56"));                            //MÃ COIL
                    product.DienAp       = Lib.ToDecimal(grvData.GetRowCellValue(i, "F57"));                           //Điện áp (V)
                    product.TanSo        = Lib.ToDecimal(grvData.GetRowCellValue(i, "F58"));                           //Tần số
                    valueString          = Lib.ToString(grvData.GetRowCellValue(i, "F59"));
                    product.DongDienMin  = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[0] : "0"); //Dòng điện Io
                    product.DongDienMax  = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[1] : "0"); //Dòng điện Io
                    valueString          = Lib.ToString(grvData.GetRowCellValue(i, "F60"));
                    product.NhapLucMin   = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[0] : "0"); //Nhập lực Wo
                    product.NhapLucMax   = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[1] : "0"); //Nhập lực Wo
                    valueString          = Lib.ToString(grvData.GetRowCellValue(i, "F61"));
                    product.VongQuayMin  = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[0] : "0"); //Vòng quay
                    product.VongQuayMax  = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[1] : "0"); //Vòng quay
                    product.TiengOn      = valueString = Lib.ToString(grvData.GetRowCellValue(i, "F62"));
                    product.TiengOnMin   = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[0] : "0"); //TIẾNG ỒN
                    product.TiengOnMax   = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[1] : "0"); //TIẾNG ỒN
                    valueString          = Lib.ToString(grvData.GetRowCellValue(i, "F63"));
                    product.DoRungFFTMin = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[0] : "0"); //ĐỘ RUNG FFT
                    product.DoRungFFTMax = Lib.ToDecimal(valueString.Contains(spt) ? valueString.Split(spt)[1] : "0"); //ĐỘ RUNG FFT
                    product.Goal         = Lib.ToString(grvData.GetRowCellValue(i, "F64"));
                    #endregion

                    List <string> lstCommand = new List <string>();
                    if (!chkWorking.Checked)
                    {
                        if (product.ID == 0)
                        {
                            product.ID = (int)ProductBO.Instance.Insert(product);
                            //Thêm các hạng mục check theo nhóm sản phẩm
                            string sqlInitWorking = string.Format("EXEC dbo.CreateProductWorking_ByGroupID {0},{1}", groupID, product.ID);
                            lstCommand.Add(sqlInitWorking);
                            lstProduct.Add(product);
                        }
                        else
                        {
                            ProductBO.Instance.Update(product);
                        }
                    }
                    //Sinh các câu lệnh update động các mục kiểm tra
                    for (int j = 0; j < grvData.Columns.Count; j++)
                    {
                        string rule = Lib.ToString(grvData.GetRowCellValue(3, grvData.Columns[j]));
                        if (string.IsNullOrEmpty(rule))
                        {
                            continue;
                        }
                        string value = Lib.ToString(grvData.GetRowCellValue(i, grvData.Columns[j]));
                        value = value.Replace("'", "");
                        //if (string.IsNullOrEmpty(value)) continue;
                        string min = "";
                        string max = "";
                        if (value.Contains(spt))
                        {
                            string[] arrValue = value.Split(spt);
                            min = arrValue[0].Trim();
                            max = arrValue[1].Trim();
                        }
                        else
                        {
                            min = max = Lib.ToDecimal(value).ToString();
                        }

                        string[] arrCD = rule.Split(';');
                        for (int h = 0; h < arrCD.Length; h++)
                        {
                            string[] arrW = arrCD[h].Trim().Split('_');
                            if (arrW.Length <= 1)
                            {
                                continue;
                            }

                            if (arrW.Length == 3)                            //chứa cả nhóm sản phẩm,mã công đoạn, stt mục kiểm tra
                            {
                                string groupCode1 = arrW[0].Trim();
                                if (groupCode.ToLower() != groupCode1.ToLower())
                                {
                                    continue;
                                }

                                string stepCode  = arrW[1].Trim();
                                string sortOrder = arrW[2].Trim();
                                string sql       = getSqlGroup(value, min, max, sortOrder, stepCode, product.ID, groupCode1);
                                lstCommand.Add(sql);
                            }

                            if (arrW.Length == 2)                            //chỉ chứa mã công đoạn, stt mục kiểm tra
                            {
                                string stepCode = arrW[0].Trim();

                                string sortOrder = arrW[1].Trim();
                                string sql       = getSql(value, min, max, sortOrder, stepCode, product.ID);
                                lstCommand.Add(sql);
                            }
                        }
                    }

                    if (lstCommand.Count > 0)
                    {
                        string sqlRun = string.Join(";", lstCommand);
                        LibIE.ExcuteSQL(sqlRun);
                    }
                }
                catch (Exception ex)
                {
                    //lstError.Add(productCode);
                    MessageBox.Show("Lỗi lưu dữ liệu tại dòng " + i);
                }
                //stopwatch.Stop();
                //MessageBox.Show(stopwatch.ElapsedMilliseconds.ToString());
            }
        }
コード例 #10
0
ファイル: frmProductDetailH.cs プロジェクト: Dung12345678/Dao
        /// <summary>
        /// Cất dữ liệu
        /// </summary>
        /// <returns></returns>
        bool saveData()
        {
            if (!ValidateForm())
            {
                return(false);
            }

            Product.ProductGroupID  = TextUtils.ToInt(cboGroup.EditValue);  //"NHÓM SẢN PHẨM"
            Product.ProductTypeCode = txtProductTypeCode.Text.Trim();       //"LOẠI SẢN PHẨM#"
            Product.ProductCode     = txtCode.Text.Trim();                  //PRODUCT ID
            Product.ProductName     = txtDes.Text.Trim();                   //MÔ TẢ SẢN PHẨM
            Product.RatioCode       = txtRatio.Text.Trim();                 //Giảm tốc
            Product.ProductDate     = TextUtils.ToDate2(dtpDate.EditValue); //NGÀY LẬP
            Product.XuatLucSealCap  = txtXuatLucSealCap.Text.Trim();        //"HƯỚNG TRỤC XUẤT LỰC SEAL CAP"
            Product.LoaiMoNapDau    = txtLoaiMoNapDau.Text.Trim();          //LOẠI MỠ NẮP DẦU
            Product.LoaiMoBomHopSo  = txtLoaiMoBomHopSo.Text.Trim();        //LOẠI MỠ BƠM HỘP SỐ
            //"LỰC CHECK 1  NẮP - HỘP (N.m)"
            Product.LucCheckGearMin = txtLucCheckMin.Value;
            Product.LucCheckGearMax = txtLucCheckMax.Value;
            Product.GunNumber       = TextUtils.ToInt(txtGunNumber.Value);    //SÚNG
            Product.JobNumber       = TextUtils.ToInt(txtJobNumber.Value);    //JOB
            Product.QtyOcBanGa      = TextUtils.ToInt(txtQtyOcBanGa.Value);   //BẮN GÁ
            Product.BuLongNumber    = TextUtils.ToInt(txtBuLongNumber.Value); // SỐ LUỢNG BULONG
            Product.ShootNumber     = TextUtils.ToInt(txtShootNumber.Value);  //SỐ LẦN BẮN
            Product.SetForce        = TextUtils.ToInt(txtSetForce.Value);     // đặt lực
            Product.MotorCode       = txtMotorCode.Text.Trim();               //MÃ MOTOR
            Product.CoilCode        = txtCoilCode.Text.Trim();                // Mã Coil
            Product.DienAp          = txtDienAp.Value;                        //Điện áp (V)
            Product.TanSo           = txtTanSo.Value;                         //Tần số (Hz)
            //Dòng điện Io
            Product.DongDienMin = txtDongDienMin.Value;
            Product.DongDienMax = txtDongDienMax.Value;
            //Nhập lực Wo
            Product.NhapLucMax = txtNhapLucMax.Value;
            Product.NhapLucMin = txtNhapLucMin.Value;
            //Vòng quay
            Product.VongQuayMax = txtVongQuayMax.Value;
            Product.VongQuayMin = txtVongQuayMin.Value;
            // Tiếng ồn dB
            Product.TiengOnMax = txtTiengOnMax.Value;
            Product.TiengOnMin = txtTiengOnMin.Value;
            //Độ rung FFT
            Product.DoRungFFTMax = txtDoRungMax.Value;
            Product.DoRungFFTMin = txtDoRungMin.Value;
            Product.Goal         = txtGoal.Text.Trim();// đích
            if (Product.ID > 0)
            {
                WorkingBO.Instance.Update(Product);
            }
            else
            {
                Product.ID = (int)WorkingBO.Instance.Insert(Product);
                //Sinh các công đoạn và mục kiểm tra của sản phẩm theo định dạng của nhóm sản phẩm
                LibIE.ExcuteSQL(string.Format("EXEC dbo.CreateProductWorking_ByGroupID {0},{1}", Product.ProductGroupID, Product.ID));
            }

            /*
             * Cập nhật lại các mục check sản phẩm theo các rule quy định của các công đoạn
             */
            LibIE.ExcuteSQL(string.Format("EXEC spUpdateProductWorking_ByProductID_New {0},{1}", Product.ID, Product.MURATA == "3" ? 0 : 1));
            return(true);
        }
コード例 #11
0
ファイル: frmWorkingDetailH.cs プロジェクト: Dung12345678/Dao
        /// <summary>
        /// Cất dữ liệu
        /// </summary>
        /// <returns></returns>
        bool saveData()
        {
            if (!ValidateForm())
            {
                return(false);
            }

            WorkingModel.ProductGroupID = TextUtils.ToInt(cboGroup.EditValue);
            WorkingModel.WorkingStepID  = TextUtils.ToInt(cboStep.EditValue);
            WorkingModel.WorkingName    = txtName.Text.Trim();
            WorkingModel.SortOrder      = (int)txtSortOrder.Value;

            WorkingModel.Unit          = txtUnit.Text.Trim();
            WorkingModel.ValueType     = cboValueType.SelectedIndex;
            WorkingModel.ValueTypeName = cboValueType.SelectedIndex == 0 ? "Check mark" : "Giá trị\n数値";
            WorkingModel.MaxValue      = TextUtils.ToDecimal(txtMax.Value);
            WorkingModel.MinValue      = TextUtils.ToDecimal(txtMin.Value);
            // WorkingModel.PeriodValue = WorkingModel.MinValue + "~" + WorkingModel.MaxValue;

            WorkingModel.IsGetAutoValueComport = chkAutoValue.Checked;
            WorkingModel.Comport = cboComPort.SelectedIndex + 1;

            WorkingModel.CheckValueType   = cboCheckValueType.SelectedIndex;
            WorkingModel.IsGetAutoValueIP = chkIP.Checked;
            WorkingModel.IpAddress        = txtIP.Text.Trim();
            WorkingModel.Port             = txtPort.Text.Trim();

            if (WorkingModel.ValueType == 0)//checkmark
            {
                WorkingModel.PeriodValue = txtPeriodValue.Text.Trim();
            }
            else
            {
                if (WorkingModel.CheckValueType == 1)//giá trị dạng số
                {
                    if (WorkingModel.MinValue == WorkingModel.MaxValue)
                    {
                        WorkingModel.PeriodValue = WorkingModel.MaxValue.ToString("n3");
                    }
                    else
                    {
                        WorkingModel.PeriodValue = WorkingModel.MinValue.ToString("n3") + "~" + WorkingModel.MaxValue.ToString("n3");
                    }
                }
                else
                {
                    WorkingModel.PeriodValue = txtPeriodValue.Text.Trim();
                }
            }

            if (WorkingModel.ID > 0)
            {
                WorkingBO.Instance.Update(WorkingModel);
                LibIE.ExcuteSQL(string.Format("EXEC spUpdateMultiProductWorking {0}, 1", WorkingModel.ID));
            }
            else
            {
                WorkingModel.ID = (int)WorkingBO.Instance.Insert(WorkingModel);
                LibIE.ExcuteSQL(string.Format("EXEC CreateProductWorking_ByWorkingID {0}", WorkingModel.ID));
            }
            return(true);
        }