示例#1
0
        private void kCSHủyXácNhậnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int count = 0;

            _rownIndex = grvData.FocusedRowHandle;

            foreach (int i in grvData.GetSelectedRows())
            {
                if (i < 0)
                {
                    continue;
                }
                int iD = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                ModuleErrorModel model = (ModuleErrorModel)ModuleErrorBO.Instance.FindByPK(iD);
                if (model.Status == 1)
                {
                    model.Status          = 0;
                    model.CompleteTimeKCS = TextUtils.GetSystemDate();
                    ModuleErrorBO.Instance.Update(model);
                    count++;
                }
            }
            if (count > 0)
            {
                loadGrid();
            }
        }
示例#2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                #region Khai báo Model và gán giá trị

                EventsLogErrorModel mELE = new EventsLogErrorModel();
                mELE.MessageCode  = MessageCode;
                mELE.ComputerName = TextUtils.GetHostName();
                mELE.ErrorDate    = TextUtils.GetSystemDate();
                mELE.EventName    = EventName;
                mELE.FormName     = FormName;
                mELE.ErrorContent = SystemMessage;
                EventsLogErrorBO.Instance.Insert(mELE);

                #endregion
            }
            catch
            {
                return;
            }
            finally {
                this.Close();
            }
        }
示例#3
0
        private void btnKCS_XacNhan_Click(object sender, EventArgs e)
        {
            int count = 0;

            if (MessageBox.Show("Bạn có chắc muốn xác nhận những sự không phù hợp này đã được khắc phục?", TextUtils.Caption, MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
            {
                _rownIndex = grvData.FocusedRowHandle;

                foreach (int i in grvData.GetSelectedRows())
                {
                    if (i < 0)
                    {
                        continue;
                    }
                    int           iD    = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                    MisMatchModel model = (MisMatchModel)MisMatchBO.Instance.FindByPK(iD);
                    if (model.StatusTK == 1)
                    {
                        model.StatusKCS    = 1;
                        model.CompleteTime = TextUtils.GetSystemDate();
                        MisMatchBO.Instance.Update(model);
                        count++;
                    }
                }
            }
            if (count > 0)
            {
                loadGrid();
            }
        }
示例#4
0
        private void btnTransfer_Click(object sender, EventArgs e)
        {
            if (PaymentTableItem.ID <= 0)
            {
                return;
            }

            foreach (int i in grvData.GetSelectedRows())
            {
                int       voucherID = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                DataRow[] drs       = _dtDebt.Select("PayVoucherID = " + voucherID);
                if (drs.Length > 0)
                {
                    continue;
                }
                PayVoucherDebtModel model = new PayVoucherDebtModel();
                model.PayVoucherID       = voucherID;
                model.PaymentTableItemID = PaymentTableItem.ID;
                model.CreatedBy          = Global.AppUserName;
                model.CreatedDate        = TextUtils.GetSystemDate();
                PayVoucherDebtBO.Instance.Insert(model);
            }

            loadDebt();
        }
示例#5
0
        private void btnCopyN_Click(object sender, EventArgs e)
        {
            //chuyển thông số đích sang nguồns

            int groupID = TextUtils.ToInt(cboMaterialGroupN.EditValue);

            if (groupID == 0)
            {
                MessageBox.Show("Bạn hãy chọn nhóm vật tư.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            foreach (int rowHandle in grvData.GetSelectedRows())
            {
                string    name = grvData.GetRowCellValue(rowHandle, colNameN).ToString();
                DataTable dt;
                dt = TextUtils.Select("select Name from MaterialParameters where MaterialGroupID =" + groupID + " and Name = N'" + name + "'");
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("Tên thông số [" + name + "] này đã tồn tại!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                        continue;
                    }
                }

                ProcessTransaction pt = new ProcessTransaction();
                pt.OpenConnection();
                pt.BeginTransaction();
                try
                {
                    MaterialParametersModel model = new MaterialParametersModel();

                    model.CreatedDate = TextUtils.GetSystemDate();
                    model.CreatedBy   = Global.AppUserName;
                    model.UpdatedDate = model.CreatedDate;
                    model.UpdatedBy   = Global.AppUserName;

                    model.Name            = grvData.GetRowCellValue(rowHandle, colNameN).ToString();
                    model.MaterialGroupID = TextUtils.ToInt(cboMaterialGroupN.EditValue);

                    DataTable dtmax = TextUtils.Select("SELECT isnull(MAX(STT),0) FROM MaterialParameters with(nolock) where MaterialParameters.MaterialGroupID = "
                                                       + model.MaterialGroupID);
                    model.STT = TextUtils.ToInt(dtmax.Rows[0][0].ToString()) + 1;

                    pt.Insert(model);
                    pt.CommitTransaction();
                    loadGridParasN();
                }
                catch (Exception)
                {
                }
                finally
                {
                    pt.CloseConnection();
                }
            }
        }
示例#6
0
        private void btnSaveN_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (checkValidN())
                {
                    MaterialParametersModel model = new MaterialParametersModel();

                    if (isAddN)
                    {
                        model.CreatedDate = TextUtils.GetSystemDate();
                        model.CreatedBy   = Global.AppUserName;
                        model.UpdatedDate = model.CreatedDate;
                        model.UpdatedBy   = Global.AppUserName;
                    }
                    else
                    {
                        int ID = Convert.ToInt32(grvDataN.GetFocusedRowCellValue(colID).ToString());
                        model             = (MaterialParametersModel)MaterialParametersBO.Instance.FindByPK(ID);
                        model.UpdatedDate = model.CreatedDate;
                        model.UpdatedBy   = Global.AppUserName;
                    }

                    model.Name            = txtNameN.Text;
                    model.MaterialGroupID = TextUtils.ToInt(cboMaterialGroupN.EditValue);

                    if (isAddN)
                    {
                        DataTable dt = TextUtils.Select("SELECT isnull(MAX(STT),0) FROM MaterialParameters with(nolock) where MaterialParameters.MaterialGroupID = " + model.MaterialGroupID);
                        model.STT = TextUtils.ToInt(dt.Rows[0][0].ToString()) + 1;
                        pt.Insert(model);
                    }
                    else
                    {
                        pt.Update(model);
                    }

                    pt.CommitTransaction();

                    loadGridParasN();
                    SetInterfaceN(false);
                    cboMaterialGroupN.Enabled = true;
                    ClearInterfaceN();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                Model.Name        = txtName.Text.Trim();
                Model.ParentID    = TextUtils.ToInt(cboParent.SelectedValue);
                Model.Type        = Type;
                Model.Description = txtDes.Text.Trim();
                Model.Extension   = txtExtension.Text.Trim();
                Model.Contain     = txtContain.Text.Trim();

                if (ParentID == 0)
                {
                    Model.ParentPath = DPath;
                    Model.Path       = Path.Combine(DPath, txtName.Text.Trim());
                }
                else
                {
                    Model.ParentPath = ((DesignStructureModel)DesignStructureBO.Instance.FindByPK(ParentID)).Path;
                    Model.Path       = Path.Combine(Model.ParentPath, txtName.Text.Trim());
                }

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                CurentNode = Model.ID;
                pt.CommitTransaction();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#8
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkValid())
                {
                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();
                    if (!isAdd)
                    {
                        _model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByPK(TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID)));
                    }

                    _model.KeyName     = txtKey.Text.Trim();
                    _model.KeyValue    = txtDuongDan.Text.Trim();
                    _model.Description = txtMoTa.Text.Trim();

                    if (isAdd)
                    {
                        _model.CreatedDate = TextUtils.GetSystemDate();
                        _model.CreatedBy   = Global.AppUserName;
                        _model.UpdatedDate = _model.CreatedDate;
                        _model.UpdatedBy   = Global.AppUserName;
                        _model.ID          = (int)pt.Insert(_model);
                    }
                    else
                    {
                        _model.UpdatedDate = TextUtils.GetSystemDate();
                        _model.UpdatedBy   = Global.AppUserName;
                        pt.Update(_model);
                    }

                    pt.CommitTransaction();
                    pt.CloseConnection();
                    LoadData();
                    if (isAdd)
                    {
                        MessageBox.Show("Tạo mới thành công!");
                    }
                    else
                    {
                        MessageBox.Show("Cập nhật thành công!");
                    }
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Model.Code         = txtCode.Text.Trim();
                Model.Name         = txtName.Text.Trim();
                Model.TotalTime    = (double)txtTotalTime.Value;
                Model.ProductID    = TextUtils.ToInt(leProducts.EditValue);
                Model.WorkStatusID = cboStatus.SelectedIndex;
                Model.WorkTypeID   = cboWorkType.SelectedIndex;
                Model.Type         = cboType.SelectedIndex;
                Model.TotalScore   = TextUtils.ToDouble(txtTotalScore.Value);
                Model.Priority     = TextUtils.ToInt(txtPriority.Value);
                Model.Description  = txtDescription.Text.Trim();

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                pt.CommitTransaction();

                MessageBox.Show("Lưu trữ thành công!", "Thông báo");
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            { pt.CloseConnection(); }
        }
示例#10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //Kiểm tra validate để chuẩn bị cho thao tác
                if (checkValid())
                {
                    //Khai báo một model của bảng Department trong cơ sở dữ liệu
                    DepartmentModel dModel;
                    if (_isAdd)//nếu bạn muốn Insert một bản ghi
                    {
                        dModel             = new DepartmentModel();
                        dModel.CreatedDate = TextUtils.GetSystemDate();
                        dModel.UpdatedDate = dModel.CreatedDate;
                        dModel.CreatedBy   = Global.AppUserName;
                        dModel.UpdatedBy   = Global.AppUserName;
                    }
                    else
                    {
                        //nếu bạn muốn update một bản ghi
                        int ID = TextUtils.ToInt(grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID"));
                        dModel             = (DepartmentModel)DepartmentBO.Instance.FindByPK(ID);
                        dModel.UpdatedDate = TextUtils.GetSystemDate();
                        dModel.UpdatedBy   = Global.AppUserName;
                    }
                    //gán các giá trị vào các trường để phục vụ việc thêm, sửa
                    dModel.Code             = txtCode.Text;
                    dModel.Name             = txtName.Text;
                    dModel.Status           = cboStatus.SelectedIndex;
                    dModel.Email            = txtEmail.Text;
                    dModel.HeadofDepartment = TextUtils.ToInt(leHead.EditValue);

                    if (_isAdd)
                    {
                        //lệnh này tương tự với câu lệnh insert trong sql
                        DepartmentBO.Instance.Insert(dModel);
                    }
                    else
                    {
                        DepartmentBO.Instance.Update(dModel);//lệnh này tương tự với câu lệnh update trong sql
                    }
                    LoadData();
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#11
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                if (Model == null)
                {
                    Model = new FormAndFunctionModel();
                }

                Model.Name = txtName.Text.Trim();
                Model.Code = txtCode.Text.Trim();
                Model.FormAndFunctionGroupID = TextUtils.ToInt(leParentCat.EditValue);
                Model.IsHide = false;

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                pt.CommitTransaction();

                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#12
0
        private void btnDeleteDebt_Click(object sender, EventArgs e)
        {
            if (grvDebt.SelectedRowsCount == 0)
            {
                return;
            }

            foreach (int i in grvDebt.GetSelectedRows())
            {
                long id = TextUtils.ToInt64(grvDebt.GetRowCellValue(i, colDebtID));
                PayVoucherDebtModel model = (PayVoucherDebtModel)PayVoucherDebtBO.Instance.FindByPK(id);
                model.CompletedDate = TextUtils.GetSystemDate();
                PayVoucherDebtBO.Instance.Update(model);
            }
            loadDebt();
        }
示例#13
0
        private void PrintReportToolStripButton_Click(object sender, EventArgs e)
        {
            /* Chọn máy in trong danh sách */
            if (mode == 1)
            {
                PrintDialog  PrintDialog1 = new PrintDialog();
                DialogResult result       = PrintDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    rpt.PrintOptions.PrinterName = PrintDialog1.PrinterSettings.PrinterName;
                    rpt.PrintOptions.PaperSize   = CrystalDecisions.Shared.PaperSize.PaperLetter;
                    rpt.PrintToPrinter(1, true, 1, 99); //; crystalReportViewer1.ViewCount);

                    string sql = "Insert Into PrintVAT(DateTime, FolioNo, RoomNo, GuestName, CompanyName, TaxCode, Address,AmountBeforeTax, VAT5, VAT10, AmountAfterTax, FullName,UserName, ComputerName, PrinterName,Status) Values " +
                                 " ('" + TextUtils.GetSystemDate().ToString("MM/dd/yyy hh:mm:ss tt") + "', " + Convert.ToInt32(FormulaFieldsValue[5]) + " ,'" + FormulaFieldsValue[0] + "',N'" + FormulaFieldsValue[6] + "', " +
                                 " N'" + (FormulaFieldsValue[7]) + "', N'" + (FormulaFieldsValue[8]) + "',N'" + (FormulaFieldsValue[9]) + "', " +
                                 " '" + ((FormulaFieldsValue[18])) + "', '" + ((FormulaFieldsValue[20])) + "', '" + ((FormulaFieldsValue[21])) + "','" + ((FormulaFieldsValue[22])) + "', " +
                                 " N'" + Global.AppFullName + "',N'" + Global.AppUserName + "','" + TextUtils.GetHostName() + "','" + PrintDialog1.PrinterSettings.PrinterName + "',1)";

                    TextUtils.ExcuteSQL(sql);
                    TextUtils.ExcuteSQL("Update Folio Set IsPrintVAT =1 Where ID = " + Convert.ToInt32(FormulaFieldsValue[5]));

                    //ActionPosting.InsertHistory(TextUtils.GetSystemDate(), TextUtils.GetBusinessDate(), TextUtils.ToInt(FormulaFieldsValue[5]), TextUtils.ToInt(FormulaFieldsValue[5]), FormulaFieldsValue[5], ActionPosting.HistoryType.Print,
                    //    ActionPosting.GetActionText(ActionPosting.HistoryType.Print, "", "Print VAT Invoice "),
                    //    Global.UserName, "", "Print VAT Invoice", TextUtils.ToDecimal((FormulaFieldsValue[22])), TextUtils.GetHostName() + PrintDialog1.PrinterSettings.PrinterName, "", "", "");
                }
            }
            else
            {
                #region Khong hoi may in
                ////rpt.PrintOptions.PrinterName = GetDefaultPrinter();
                ////rpt.PrintToPrinter(1, true, 1, 99); //; crystalReportViewer1.ViewCount);
                #endregion

                PrintDialog  PrintDialog1 = new PrintDialog();
                DialogResult result       = PrintDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    rpt.PrintOptions.PrinterName = PrintDialog1.PrinterSettings.PrinterName;
                    rpt.PrintOptions.PaperSize   = CrystalDecisions.Shared.PaperSize.PaperA4;
                    rpt.PrintToPrinter(1, true, 1, 99);
                    //ActionPosting.InsertHistory(Convert.ToDateTime(TextUtils.GetSystemDate()), Convert.ToDateTime(TextUtils.GetBusinessDate()), TextUtils.ToInt(FormulaFieldsValue[6]), TextUtils.ToInt(FormulaFieldsValue[6]), "", ActionPosting.HistoryType.Print,
                    //    ActionPosting.GetActionText(ActionPosting.HistoryType.Print, "", "Print Folio "),
                    //    Global.UserName, "", "PrintFolio", TextUtils.ToDecimal((FormulaFieldsValue[19])), TextUtils.GetHostName(), "", "", "");
                }
            }
        }
示例#14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (checkValid())
                {
                    DepartmentModel dModel;
                    if (isAdd)
                    {
                        dModel             = new DepartmentModel();
                        dModel.CreatedDate = TextUtils.GetSystemDate();
                        dModel.UpdatedDate = dModel.CreatedDate;
                        dModel.CreatedBy   = Global.AppUserName;
                        dModel.UpdatedBy   = Global.AppUserName;
                    }
                    else
                    {
                        int ID = Convert.ToInt32(grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID").ToString());
                        dModel             = (DepartmentModel)DepartmentBO.Instance.FindByPK(ID);
                        dModel.UpdatedDate = TextUtils.GetSystemDate();
                        dModel.UpdatedBy   = Global.AppUserName;
                    }
                    dModel.Code             = txtCode.Text;
                    dModel.Name             = txtName.Text;
                    dModel.Status           = cboStatus.SelectedIndex;
                    dModel.Email            = txtEmail.Text;
                    dModel.HeadofDepartment = TextUtils.ToInt(leHead.EditValue);

                    if (isAdd)
                    {
                        DepartmentBO.Instance.Insert(dModel);
                    }
                    else
                    {
                        DepartmentBO.Instance.Update(dModel);
                    }

                    LoadData();
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#15
0
        public void PopupInformationSys()
        {
            try
            {
                lblVersion.Text = string.Format("Phiên bản : {0}   |   ", CURRENT_VERSION);
                // Get Connection string.
                string[] _Conn = Global.ConnectionString.Split(';');
                lblServer.Text = _Conn[0].Split('=')[1].ToString().Trim() + " / " + _Conn[1].Split('=')[1].ToString().Trim() + "   |   ";

                lblBusinessDate.Text = "System Date: " + TextUtils.GetSystemDate().ToString("dd/MM/yyyy") + "   |  ";
                if (Global.IsNotCreateSession)
                {
                    lblUser.Text = "Login By: " + Global.AppFullName + "  |  ";
                }
                else
                {
                    lblUser.Text = "Login By: " + Global.AppFullName + " (Shift ID: " + Global.ShiftID + ")   |  ";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi" + ex.Message);
            }
        }
示例#16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                if (Model == null)
                {
                    Model = new ProductGroupModel();
                }

                Model.Name     = txtName.Text.Trim().ToUpper();
                Model.ParentID = ParentID;

                if (ParentID == 0)
                {
                    Model.ParentPath = DPath;
                    Model.Path       = Path.Combine(DPath, txtName.Text.Trim());
                }
                else
                {
                    Model.ParentPath = ((ProductGroupModel)ProductGroupBO.Instance.FindByPK(ParentID)).Path;
                    Model.Path       = Path.Combine(Model.ParentPath, txtName.Text.Trim().ToUpper());
                }

                Model.Description = txtDes.Text.Trim();
                Model.Type        = 2;

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);

                    Directory.CreateDirectory(Model.Path);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);

                    if (_currentPath != Model.Path)
                    {
                        Directory.Move(_currentPath, Model.Path);
                    }
                }

                CurentNode = Model.ID;
                pt.CommitTransaction();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();

            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Model.ProjectCode      = txtProjectCode.Text.Trim();
                Model.ProjectName      = txtProjectName.Text.Trim();
                Model.ContractCode     = txtContractCode.Text.Trim();
                Model.ContractName     = txtContractName.Text.Trim();
                Model.Curator          = txtCurator.Text.Trim();
                Model.Reception        = txtReception.Text.Trim();
                Model.Requirement      = txtRequirement.Text.Trim();
                Model.Status           = cboStatus.SelectedIndex;
                Model.CustomerName     = txtCustomerName.Text.Trim();
                Model.LastCustomerName = txtLastCustomerName.Text.Trim();
                Model.Priority         = txtPriority.Text.Trim();
                Model.Description      = txtDescription.Text.Trim();

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;
                    Model.UpdatedDate = Model.CreatedDate;
                    Model.UpdatedBy   = Global.AppUserName;
                    Model.ID          = (int)pt.Insert(Model);
                }
                else
                {
                    Model.UpdatedDate = TextUtils.GetSystemDate();
                    Model.UpdatedBy   = Global.AppUserName;
                    pt.Update(Model);
                }

                if (_listProducts.Count > 0)
                {
                    foreach (ProductsModel item in _listProducts)
                    {
                        item.CreatedBy     = Global.AppUserName;
                        item.CreatedDate   = TextUtils.GetSystemDate();
                        item.UpdatedDate   = item.CreatedDate;
                        item.UpdatedBy     = Global.AppUserName;
                        item.ProjectInfoID = Model.ID;
                        pt.Insert(item);
                    }
                }
                //MessageBox.Show("Lưu trữ thành công!", "Thông báo");
                pt.CommitTransaction();
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#18
0
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }
                string oldName = Material.Name;
                Material.Name            = txtName.Text.Trim().ToUpper();
                Material.Code            = txtCode.Text.Trim();
                Material.CustomerID      = TextUtils.ToInt(cboHang.EditValue);
                Material.MaterialGroupID = TextUtils.ToInt(leParentCat.EditValue);

                Material.Unit               = txtDonVi.Text;
                Material.Note               = txtGhiChu.Text;
                Material.Price              = TextUtils.ToDecimal(txtPrice.Text);
                Material.PriceTemp          = TextUtils.ToDecimal(txtPriceTemp.Text);
                Material.DeliveryPeriod     = TextUtils.ToDecimal(txtTGiaoHang.Text);
                Material.DeliveryPeriodTemp = txtTGiaoHangTemp.Text.Trim();
                Material.ThoiGianGHCuoi     = txtTGiaoHangCuoi.Text;
                Material.Properties         = txtTTGiaCong.Text;
                Material.VL         = txtVatLieu.Text;
                Material.MaVatLieu  = txtVatTuNguon.Text;
                Material.Weight     = TextUtils.ToDecimal(txtWeight.Text);
                Material.StopStatus = chkTamDung.Checked;
                Material.IsUse      = chkThuongSuDung.Checked;

                if (Material.ID <= 0)
                {
                    Material.CreatedDate = TextUtils.GetSystemDate();
                    Material.CreatedBy   = Global.AppUserName;
                    Material.UpdatedDate = Material.CreatedDate;
                    Material.UpdatedBy   = Global.AppUserName;
                    Material.ID          = (int)pt.Insert(Material);
                }
                else
                {
                    Material.UpdatedDate = TextUtils.GetSystemDate();
                    Material.UpdatedBy   = Global.AppUserName;
                    pt.Update(Material);

                    //update tên cho file ipt
                    if (oldName != Material.Name && Material.File3D > 0)
                    {
                        using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang update tên cho file 3D..."))
                        {
                            string filePathIpt   = "Materials/" + Material.Code + ".ipt";
                            string localPath     = Path.GetTempPath();
                            string fileName      = Material.Code + ".ipt";
                            string filePathLocal = localPath + "/" + fileName;

                            DocUtils.DownloadFile(localPath, fileName, filePathIpt);

                            IPTDetail.WriteName(filePathLocal, Material.Name);

                            DocUtils.UploadFile(filePathLocal, "Materials");
                        }
                    }
                }

                //Lưu trữ thông số
                for (int i = 0; i < grvData.RowCount; i++)
                {
                    int       paraID     = TextUtils.ToInt(grvData.GetRowCellValue(i, colID));
                    int       materialID = TextUtils.ToInt(grvData.GetRowCellValue(i, colMaterialID));
                    DataTable dt         = TextUtils.Select("MaterialParameterLink", new Expression("MaterialID", materialID)
                                                            .And(new Expression("MaterialParameterID", paraID)));
                    if (dt.Rows.Count > 0)
                    {
                        continue;
                    }
                    MaterialParameterLinkModel model = new MaterialParameterLinkModel();
                    model.MaterialID          = Material.ID;
                    model.MaterialParameterID = paraID;
                    pt.Insert(model);
                }

                pt.CommitTransaction();
                _isSaved = true;
                loadGridPara();
                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#19
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (checkValid())
                {
                    ModuleFilmModel dModel;
                    if (_isAdd)
                    {
                        dModel = new ModuleFilmModel();
                    }
                    else
                    {
                        int ID = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID));
                        dModel = (ModuleFilmModel)ModuleFilmBO.Instance.FindByPK(ID);
                    }

                    dModel.Code           = txtCode.Text.ToUpper().Trim();
                    dModel.LastDateChange = TextUtils.ToDate(deUpdatedDate.EditValue.ToString());
                    dModel.LastTimeChange = TextUtils.ToInt(txtTime.Text.Trim());
                    dModel.ModuleID       = ModuleID;

                    if (_isAdd)
                    {
                        pt.Insert(dModel);
                    }
                    else
                    {
                        pt.Update(dModel);

                        if (txtReason.Enabled)
                        {
                            ModuleFilmHistoryModel hModel = new ModuleFilmHistoryModel();
                            hModel.ModuleFilmID   = dModel.ID;
                            hModel.LastTimeChange = dModel.LastTimeChange;
                            hModel.LastDateChange = dModel.LastDateChange;
                            hModel.Reason         = txtReason.Text.Trim();
                            hModel.UpdatedDate    = TextUtils.GetSystemDate();
                            hModel.UpdatedBy      = Global.AppUserName;
                            hModel.Code           = dModel.Code;
                            pt.Insert(hModel);
                        }
                    }

                    pt.CommitTransaction();

                    LoadData();
                    setInterface(false);
                    clearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#20
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            DocUtils.InitFTPTK();
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang up file lên server!"))
                {
                    foreach (string filePath in ofd.FileNames)
                    {
                        ProcessTransaction pt = new ProcessTransaction();
                        pt.OpenConnection();
                        pt.BeginTransaction();
                        try
                        {
                            MisMatchImageModel errorImageModel;
                            bool isAdd = true;
                            if (!MisMatchImageBO.Instance.CheckExist("FileName", Path.GetFileName(filePath)))
                            {
                                errorImageModel = new MisMatchImageModel();
                            }
                            else
                            {
                                errorImageModel = (MisMatchImageModel)MisMatchImageBO.Instance.FindByAttribute("FileName", Path.GetFileName(filePath))[0];
                                isAdd           = false;
                            }

                            FileInfo fInfo = new FileInfo(filePath);

                            string ftpFolderPath = "Modules\\KPHImage\\" + MisMatch.Code;

                            errorImageModel.CreatedDate = TextUtils.GetSystemDate();
                            errorImageModel.CreatedBy   = Global.LoginName;
                            errorImageModel.FileName    = Path.GetFileName(filePath);
                            errorImageModel.Size        = fInfo.Length;
                            errorImageModel.FilePath    = ftpFolderPath + "\\" + errorImageModel.FileName;
                            errorImageModel.MisMatchID  = MisMatch.ID;

                            if (isAdd)
                            {
                                errorImageModel.ID = (int)pt.Insert(errorImageModel);
                            }
                            else
                            {
                                pt.Update(errorImageModel);
                            }

                            if (!DocUtils.CheckExits(ftpFolderPath))
                            {
                                DocUtils.MakeDir(ftpFolderPath);
                            }
                            DocUtils.UploadFile(filePath, ftpFolderPath);

                            pt.CommitTransaction();
                        }
                        catch (Exception)
                        {
                        }
                        finally
                        {
                            pt.CloseConnection();
                        }
                    }

                    loadGridImage();
                }
            }
        }
示例#21
0
        private void btnUpIPT_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "File .ipt|*ipt|All File|*.*";
            ofd.Multiselect      = false;
            ofd.InitialDirectory = Settings.Default.TK_IptPath;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Settings.Default.TK_IptPath = Path.GetDirectoryName(ofd.FileName);
                Settings.Default.Save();

                IPTDetail.LoadData(ofd.FileName);

                #region Check Validate
                if (Material.Code.Replace(")", "#").Replace("/", "#") != Path.GetFileNameWithoutExtension(ofd.FileName).Replace(")", "#").Replace("/", "#"))
                {
                    MessageBox.Show("Tên của file ipt không giống Mã vật tư!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (IPTDetail.Code != txtCode.Text.Trim())
                {
                    MessageBox.Show("Mã vật tư trong IProperties không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (IPTDetail.Hang != cboHang.Text)
                {
                    MessageBox.Show("Hãng trong IProperties không đúng!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                #endregion

                DocUtils.InitFTPTK();

                ProcessTransaction pt = new ProcessTransaction();
                pt.OpenConnection();
                pt.BeginTransaction();
                try
                {
                    using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang up file..."))
                    {
                        FileInfo fInfo = new FileInfo(ofd.FileName);

                        #region MaterialFile
                        MaterialFileModel fileModel;
                        bool      isAdd = true;
                        DataTable dt    = TextUtils.Select("select Path, MaterialID, MaterialCode from vMaterialFile with(nolock) where FileType = 0 and MaterialID = "
                                                           + Material.ID + " and MaterialCode = '" + Path.GetFileNameWithoutExtension(ofd.FileName).Replace(")", "/") + "'");

                        if (dt.Rows.Count > 0)
                        {
                            fileModel             = (MaterialFileModel)MaterialFileBO.Instance.FindByAttribute("Name", Path.GetFileName(ofd.FileName))[0];
                            isAdd                 = false;
                            fileModel.UpdatedDate = TextUtils.GetSystemDate();
                            fileModel.UpdatedBy   = Global.AppUserName;
                        }
                        else
                        {
                            fileModel             = new MaterialFileModel();
                            fileModel.CreatedDate = TextUtils.GetSystemDate();
                            fileModel.CreatedBy   = Global.AppUserName;
                            fileModel.UpdatedDate = Material.CreatedDate;
                            fileModel.UpdatedBy   = Global.AppUserName;
                        }

                        fileModel.Extension    = Path.GetExtension(ofd.FileName);
                        fileModel.Datemodified = fInfo.LastWriteTime;
                        fileModel.Length       = fInfo.Length;
                        fileModel.Name         = Path.GetFileName(fInfo.FullName);
                        fileModel.Path         = "Materials/" + Path.GetFileName(fInfo.FullName);
                        fileModel.IsDeleted    = false;
                        fileModel.FileType     = 0;//0 là file 3D cơ khí, 1 là datasheet
                        #endregion

                        if (isAdd)
                        {
                            fileModel.ID = (int)pt.Insert(fileModel);

                            #region Insert MaterialFileLink
                            //Thêm link giữa file với vật tư
                            MaterialFileLinkModel fileLinkModel = new MaterialFileLinkModel();
                            fileLinkModel.MaterialFileID = fileModel.ID;
                            fileLinkModel.MaterialID     = Material.ID;
                            pt.Insert(fileLinkModel);
                            #endregion
                        }
                        else
                        {
                            pt.Update(fileModel);

                            #region Update material if value different
                            //if (Material.VL != IPTDetail.VL)
                            //{
                            //    frmCompareIPT frm = new frmCompareIPT();
                            //    frm.OldValue = Material.VL;
                            //    frm.IPTValue = IPTDetail.VL;
                            //    if (frm.ShowDialog() == DialogResult.OK)
                            //    {
                            //        string value = frm.RightValue;
                            //        Material.VL = value;
                            //        pt.Update(Material);

                            //        IPTDetail.GetIproperties(ofd.FileName);
                            //    }
                            //}
                            #endregion
                        }

                        #region write Title into ipt file
                        try
                        {
                            IPTDetail.WriteName(ofd.FileName, Material.Name);
                        }
                        catch (Exception)
                        {
                        }
                        #endregion

                        #region Update Material
                        //Update dữ liệu trong iproperties vào trong vật tư
                        Material.Note       = IPTDetail.Note;
                        Material.Unit       = IPTDetail.Unit;
                        Material.VL         = IPTDetail.VL;
                        Material.MaVatLieu  = IPTDetail.MaVatLieu;
                        Material.Properties = IPTDetail.Properties;
                        Material.Author     = IPTDetail.Author;

                        pbAnh.InitialImage = null;
                        pbAnh.Image        = null;

                        ConfigSystemModel cf        = (ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "MaterialImagePath")[0];//
                        string            imagePath = cf.KeyValue + "\\" + Material.Code.Replace("/", ")") + ".png";
                        Bitmap            bit       = new Bitmap(IPTDetail.Image, IPTDetail.Image.Width / 3, IPTDetail.Image.Height / 3);
                        bit.Save(imagePath, ImageFormat.Png);

                        Material.ImagePath = imagePath;
                        Material.File3D    = 1;
                        pt.Update(Material);
                        #endregion

                        DocUtils.UploadFile(ofd.FileName, "Materials");

                        pt.CommitTransaction();

                        loadIpt();

                        #region Load textbox
                        txtGhiChu.Text     = Material.Note;
                        txtDonVi.Text      = Material.Unit;
                        txtVatLieu.Text    = Material.VL;
                        txtVatTuNguon.Text = Material.MaVatLieu;
                        txtTTGiaCong.Text  = Material.Properties;
                        #endregion
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Up file không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                finally
                {
                    pt.CloseConnection();
                }
            }
        }
示例#22
0
        void Save()
        {
            //ProcessTransaction pt = new ProcessTransaction();
            //pt.OpenConnection();
            //pt.BeginTransaction();
            using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát", "Đang tạo thông số vật tư"))
            {
                try
                {
                    string             parentGroupCode = Path.GetFileNameWithoutExtension(btnBrowse.Text);
                    ArrayList          listGroup       = MaterialGroupBO.Instance.FindByAttribute("Code", parentGroupCode);
                    MaterialGroupModel parentGroup     = (MaterialGroupModel)listGroup[0];
                    string             currentGroup    = "TPAVT." + cboSheet.SelectedValue.ToString().Split('-')[0].Trim();

                    #region Material Group
                    MaterialGroupModel thisGroup;
                    if (!MaterialGroupBO.Instance.CheckExist("Code", currentGroup))
                    {
                        thisGroup             = new MaterialGroupModel();
                        thisGroup.Code        = currentGroup;
                        thisGroup.Name        = cboSheet.SelectedValue.ToString().Split('-')[1].Trim();
                        thisGroup.CreatedDate = TextUtils.GetSystemDate();
                        thisGroup.CreatedBy   = Global.AppUserName;
                        thisGroup.UpdatedDate = thisGroup.CreatedDate;
                        thisGroup.UpdatedBy   = Global.AppUserName;
                        //thisGroup.ID = (int)pt.Insert(thisGroup);
                        thisGroup.ID = (int)MaterialGroupBO.Instance.Insert(thisGroup);
                    }
                    else
                    {
                        thisGroup = (MaterialGroupModel)MaterialGroupBO.Instance.FindByAttribute("Code", currentGroup)[0];
                    }
                    #endregion Material Group

                    //List<MaterialParameterValueModel> listTemParaValue = new List<MaterialParameterValueModel>();

                    for (int i = 0; i < grvData.RowCount; i++)
                    {
                        if (i == 0)
                        {
                            for (int j = 4; j < grvData.Columns.Count; j++)
                            {
                                #region Thêm thông số kỹ thuật
                                if (grvData.GetRowCellValue(i, "F" + (j + 1)) == null)
                                {
                                    continue;
                                }
                                string thisNameTS = grvData.GetRowCellValue(i, "F" + (j + 1)).ToString().Trim();
                                if (thisNameTS == "")
                                {
                                    continue;
                                }

                                DataTable dtTS = TextUtils.Select(string.Format("Select * from MaterialParameters with(nolock) where Name=N'{0}' and MaterialGroupID ={1}", thisNameTS, thisGroup.ID));
                                MaterialParametersModel modelTSVT = null;
                                if (dtTS.Rows.Count == 0)
                                {
                                    modelTSVT                 = new MaterialParametersModel();
                                    modelTSVT.Name            = thisNameTS;
                                    modelTSVT.MaterialGroupID = thisGroup.ID;
                                    //modelTSVT.ID = (int)pt.Insert(modelTSVT);
                                    modelTSVT.ID = (int)MaterialParametersBO.Instance.Insert(modelTSVT);
                                }
                                #endregion Thông số kỹ thuật
                            }
                        }
                        else
                        {
                            if (grvData.GetRowCellValue(i, "F2") == null)
                            {
                                continue;
                            }
                            string materialCode = grvData.GetRowCellValue(i, "F2").ToString().Trim();
                            if (materialCode == "")
                            {
                                continue;
                            }

                            #region Check Customer
                            string        customerCode = grvData.GetRowCellValue(i, "F4").ToString().Trim();
                            CustomerModel thisCustomer = null;
                            if (!CustomerBO.Instance.CheckExist("Code", customerCode))
                            {
                                thisCustomer      = new CustomerModel();
                                thisCustomer.Code = customerCode.ToUpper();
                                thisCustomer.Name = customerCode.ToUpper();
                                //thisCustomer.ID = (int)pt.Insert(thisCustomer);
                                thisCustomer.ID = (int)CustomerBO.Instance.Insert(thisCustomer);
                                if (!DocUtils.CheckExits("Datasheet" + "/" + customerCode.ToUpper()))
                                {
                                    DocUtils.MakeDir("Datasheet" + "/" + customerCode.ToUpper());
                                }
                            }
                            else
                            {
                                thisCustomer = (CustomerModel)CustomerBO.Instance.FindByAttribute("Code", customerCode)[0];
                            }
                            #endregion Check Customer

                            #region Check Material
                            MaterialModel thisMaterial;
                            string        materialName = grvData.GetRowCellValue(i, "F3").ToString().Trim();
                            if (!MaterialBO.Instance.CheckExist("Code", materialCode))
                            {
                                thisMaterial                 = new MaterialModel();
                                thisMaterial.Code            = materialCode;
                                thisMaterial.Name            = materialName;
                                thisMaterial.CustomerID      = thisCustomer.ID;
                                thisMaterial.MaterialGroupID = thisGroup.ID;
                                //thisMaterial.ID = (int)pt.Insert(thisMaterial);
                                thisMaterial.ID = (int)MaterialBO.Instance.Insert(thisMaterial);
                            }
                            else
                            {
                                thisMaterial = (MaterialModel)MaterialBO.Instance.FindByAttribute("Code", materialCode)[0];
                            }
                            #endregion Check Material

                            for (int j = 4; j < grvData.Columns.Count; j++)
                            {
                                if (grvData.GetRowCellValue(i, "F" + (j + 1)) == null)
                                {
                                    continue;
                                }
                                string thisTSName = grvData.GetRowCellValue(0, "F" + (j + 1)).ToString().Trim();
                                if (thisTSName == "")
                                {
                                    continue;
                                }

                                //MaterialParametersModel modelTSVT = (MaterialParametersModel)MaterialParametersBO.Instance.
                                //    FindByExpression(new Expression("Name", thisTSName).And(new Expression("MaterialGroupID", thisGroup.ID)))[0];
                                DataTable dtTSKT = TextUtils.Select(string.Format("select * from  MaterialParameters where Name = N'{0}' and MaterialGroupID = {1}", thisTSName, thisGroup.ID));
                                if (dtTSKT.Rows.Count == 0)
                                {
                                    continue;
                                }
                                #region MaterialParameterLink
                                MaterialParameterLinkModel link = null;
                                DataTable dtlink = TextUtils.Select(string.
                                                                    Format("Select * from MaterialParameterLink with(nolock) where MaterialParameterID={0} and MaterialID ={1}", TextUtils.ToInt(dtTSKT.Rows[0]["ID"]), thisMaterial.ID));
                                if (dtlink.Rows.Count == 0)
                                {
                                    link                     = new MaterialParameterLinkModel();
                                    link.MaterialID          = thisMaterial.ID;
                                    link.MaterialParameterID = TextUtils.ToInt(dtTSKT.Rows[0]["ID"]);//modelTSVT.ID;
                                    //link.ID = (int)pt.Insert(link);
                                    link.ID = (int)MaterialParameterLinkBO.Instance.Insert(link);
                                }
                                else
                                {
                                    //link = (MaterialParameterLinkModel)MaterialParameterLinkBO.Instance.FindByPK(TextUtils.ToInt(dtlink.Rows[0]["ID"]));
                                }
                                #endregion MaterialParameterLink

                                string value = grvData.GetRowCellValue(i, "F" + (j + 1)) == null ? "" : grvData.GetRowCellValue(i, "F" + (j + 1)).ToString().Trim();
                                value = value.Trim().Replace("\n", ",").Replace("_", "-");
                                if (value != "")
                                {
                                    #region MaterialParameterValue
                                    MaterialParameterValueModel paraValue = null;
                                    DataTable dtParameterValue            = TextUtils.Select(string.
                                                                                             Format("Select * from MaterialParameterValue with(nolock) where MaterialParameterID={0} and REPLACE(ParaValue,' ','') =N'{1}'",
                                                                                                    TextUtils.ToInt(dtTSKT.Rows[0]["ID"]), value.Replace(" ", "")));
                                    if (dtParameterValue.Rows.Count == 0)
                                    {
                                        paraValue = new MaterialParameterValueModel();
                                        paraValue.MaterialParameterID = TextUtils.ToInt(dtTSKT.Rows[0]["ID"]);//modelTSVT.ID;
                                        paraValue.ParaValue           = value;
                                        //paraValue.ID = (int)pt.Insert(paraValue);
                                        paraValue.ID = (int)MaterialParameterValueBO.Instance.Insert(paraValue);
                                    }
                                    else
                                    {
                                        paraValue = (MaterialParameterValueModel)MaterialParameterValueBO.Instance.FindByPK(TextUtils.ToInt(dtParameterValue.Rows[0]["ID"]));
                                    }

                                    #endregion MaterialParameterValue

                                    #region MaterialConnect
                                    MaterialConnectModel connect   = null;
                                    DataTable            dtConnect = TextUtils.Select(string.
                                                                                      Format("Select * from MaterialConnect with(nolock) where MaterialParameterID={0} and MaterialID ={1} and MaterialParameterValueID={2}",
                                                                                             TextUtils.ToInt(dtTSKT.Rows[0]["ID"]), thisMaterial.ID, paraValue.ID));
                                    if (dtConnect.Rows.Count == 0)
                                    {
                                        connect = new MaterialConnectModel();
                                        connect.MaterialParameterID      = TextUtils.ToInt(dtTSKT.Rows[0]["ID"]);//modelTSVT.ID;
                                        connect.MaterialID               = thisMaterial.ID;
                                        connect.MaterialParameterValueID = paraValue.ID;
                                        //connect.ID = (int)pt.Insert(connect);
                                        connect.ID = (int)MaterialConnectBO.Instance.Insert(connect);
                                    }

                                    #endregion MaterialConnect
                                }
                            }
                        }
                    }

                    //pt.CommitTransaction();
                    MessageBox.Show("Thành công!");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                finally
                {
                    //pt.CloseConnection();
                }
            }
        }
示例#23
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //SqlConnection con = new SqlConnection(DBUtils.GetDBConnectionString());
                if (CheckValid())
                {
                    if (isAdd)//thêm
                    {
                        ContractTypeModel _model = new ContractTypeModel();
                        _model.Name = txtName.Text.Trim();
                        if (txtTransactionCode.Text.Trim() == "")
                        {
                            _model.ContractTypeIDs = "0";
                        }
                        else
                        {
                            _model.ContractTypeIDs = TextUtils.ToString(txtTransactionCode.Text);
                        }

                        if (txtDebitDate.Text.Trim() == "")
                        {
                            _model.DebitDate = 0;
                        }
                        else
                        {
                            _model.DebitDate = TextUtils.ToInt(txtDebitDate.Text);
                        }
                        if (txtDueDate.Text.Trim() == "")
                        {
                            _model.DueDate = 0;
                        }
                        else
                        {
                            _model.DueDate = TextUtils.ToInt(txtDueDate.Text);
                        }
                        if (txtARDate.Text.Trim() == "")
                        {
                            _model.ARDate = 0;
                        }
                        else
                        {
                            _model.ARDate = TextUtils.ToInt(txtARDate.Text);
                        }

                        _model.IsBook = chkIsBook.Checked;
                        _model.IsOTL  = chkIsOTL.Checked;


                        _model.Status      = cboStatus.SelectedIndex;
                        _model.CreatedBy   = Global.AppUserName;
                        _model.CreatedDate = TextUtils.GetSystemDate();
                        _model.UpdatedBy   = Global.AppUserName;
                        _model.UpdatedDate = TextUtils.GetSystemDate();
                        //_model.ContractTypeID = ContractTypeID;
                        ContractTypeBO.Instance.Insert(_model);
                    }
                    else//sửa
                    {
                        int ID = Convert.ToInt16(grvData.GetRowCellValue(grvData.FocusedRowHandle, "ID").ToString());

                        //ContractTypeModel _model = (ContractTypeModel)ContractTypeBO.Instance.FindByPK(ID);
                        if (this.ObjContractTypeMode != null)
                        {
                            ContractTypeModel _model = ObjContractTypeMode;
                            _model.Status = cboStatus.SelectedIndex;
                            _model.Name   = txtName.Text.Trim();
                            if (txtTransactionCode.Text.Trim() == "")
                            {
                                _model.ContractTypeIDs = "0";
                            }
                            else
                            {
                                _model.ContractTypeIDs = TextUtils.ToString(txtTransactionCode.Text);
                            }
                            if (txtDebitDate.Text.Trim() == "")
                            {
                                _model.DebitDate = 0;
                            }
                            else
                            {
                                _model.DebitDate = TextUtils.ToInt(txtDebitDate.Text);
                            }
                            if (txtDueDate.Text.Trim() == "")
                            {
                                _model.DueDate = 0;
                            }
                            else
                            {
                                _model.DueDate = TextUtils.ToInt(txtDueDate.Text);
                            }

                            _model.IsBook = chkIsBook.Checked;
                            _model.IsOTL  = chkIsOTL.Checked;

                            if (txtARDate.Text.Trim() == "")
                            {
                                _model.ARDate = 0;
                            }
                            else
                            {
                                _model.ARDate = TextUtils.ToInt(txtARDate.Text);
                            }

                            _model.UpdatedBy   = Global.AppUserName;
                            _model.UpdatedDate = TextUtils.GetSystemDate();

                            ContractTypeBO.Instance.Update(_model);
                        }
                    }
                    LoadData();
                    SetInterface(false);
                    ClearInterface();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Thêm/Sửa bị lỗi, hãy thử lại\n\n" + ex.Message, TextUtils.Caption);
            }
        }
示例#24
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                Model.BankAccount = txtBankAccount.Text.Trim();
                Model.BHXH        = txtBHXH.Text.Trim();
                Model.BHYT        = txtBHYT.Text.Trim();
                try
                {
                    Model.BirthOfDate = TextUtils.ToDate(dtpBirthOfDate.EditValue.ToString());
                }
                catch
                {
                    Model.BirthOfDate = DateTime.Now;
                }

                Model.CMTND          = txtCMTND.Text.Trim();
                Model.Code           = txtCode.Text.Trim();
                Model.DepartmentID   = TextUtils.ToInt(cboDepartment.SelectedValue);
                Model.Email          = txtEmail.Text.Trim();
                Model.EmailCom       = txtEmailCom.Text.Trim();
                Model.FullName       = txtFullName.Text;
                Model.HandPhone      = txtTelephone.Text;
                Model.HomeAddress    = txtHomeAddress.Text;
                Model.JobDescription = txtJobDescription.Text.Trim();
                Model.MST            = txtMST.Text.Trim();
                Model.Position       = txtPosition.Text;
                Model.Qualifications = txtQualifications.Text.Trim();
                Model.Sex            = cboSex.SelectedIndex;
                Model.UserGroupID    = TextUtils.ToInt(lookUpEdit1.EditValue);
                try
                {
                    Model.StartWorking = TextUtils.ToDate(dtpStartWorking.EditValue.ToString());
                }
                catch
                {
                    Model.StartWorking = DateTime.Now;
                }

                Model.ImagePath = pictureBox1.ImageLocation;
                Model.Status    = cboStatus.SelectedIndex;

                if (chkHasUser.Checked)
                {
                    Model.LoginName    = txtLoginName.Text.Trim();
                    Model.PasswordHash = MD5.EncryptPassword(txtPasswordHash.Text.Trim());
                }
                else
                {
                    Model.LoginName    = "";
                    Model.PasswordHash = "";
                }

                Model.UpdatedDate = Model.CreatedDate;
                Model.UpdatedBy   = Global.AppUserName;

                if (Model.ID == 0)
                {
                    Model.CreatedDate = TextUtils.GetSystemDate();
                    Model.CreatedBy   = Global.AppUserName;

                    Model.ID = (int)pt.Insert(Model);
                }
                else
                {
                    pt.Update(Model);
                }
                pt.CommitTransaction();
                //this.DialogResult = DialogResult.OK;
                MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (this.LoadDataChange != null)
                {
                    this.LoadDataChange(null, null);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#25
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < grvData.RowCount; i++)
            {
                string departmentCode = grvData.GetRowCellValue(i, "colPB").ToString();
                if (departmentCode == "TK")
                {
                    continue;
                }

                ProcessTransaction pt = new ProcessTransaction();
                pt.OpenConnection();
                pt.BeginTransaction();
                try
                {
                    UsersModel Model = new UsersModel();
                    try
                    {
                        Model.BirthOfDate = TextUtils.ToDate(grvData.GetRowCellValue(i, "colBirdDate").ToString());
                    }
                    catch
                    {
                        Model.BirthOfDate = DateTime.Now;
                    }

                    Model.CMTND = grvData.GetRowCellValue(i, "colCMT").ToString();
                    Model.Code  = grvData.GetRowCellValue(i, "colCode").ToString();

                    Model.DepartmentID   = ((DepartmentModel)DepartmentBO.Instance.FindByAttribute("Code", departmentCode)[0]).ID;
                    Model.FullName       = grvData.GetRowCellValue(i, "colName").ToString();
                    Model.Qualifications = grvData.GetRowCellValue(i, "colTrinhDo").ToString();
                    try
                    {
                        Model.StartWorking = TextUtils.ToDate(grvData.GetRowCellValue(i, "colStartDate").ToString());
                    }
                    catch
                    {
                        Model.StartWorking = DateTime.Now;
                    }

                    Model.Status = 0;

                    if (grvData.GetRowCellValue(i, "colLogin").ToString() != "")
                    {
                        Model.LoginName    = grvData.GetRowCellValue(i, "colLogin").ToString();
                        Model.PasswordHash = MD5.EncryptPassword("123456");
                    }
                    else
                    {
                        Model.LoginName    = "";
                        Model.PasswordHash = "";
                    }

                    if (Model.ID == 0)
                    {
                        Model.CreatedDate = TextUtils.GetSystemDate();
                        Model.CreatedBy   = Global.AppUserName;
                        Model.UpdatedDate = Model.CreatedDate;
                        Model.UpdatedBy   = Global.AppUserName;
                        Model.ID          = (int)pt.Insert(Model);
                    }
                    else
                    {
                        Model.UpdatedDate = TextUtils.GetSystemDate();
                        Model.UpdatedBy   = Global.AppUserName;
                        pt.Update(Model);
                    }
                    pt.CommitTransaction();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {
                    pt.CloseConnection();
                }
            }
        }
示例#26
0
        private void btnUpDatasheet_Click(object sender, EventArgs e)
        {
            int    cusID = 0;
            string hang  = "";

            if (CustomerID > 0)
            {
                cusID = CustomerID;
                hang  = ((CustomerModel)CustomerBO.Instance.FindByPK(CustomerID)).Name;
            }
            else
            {
                cusID = TextUtils.ToInt(grvCustomer.GetFocusedRowCellValue(colID));
                hang  = grvCustomer.GetFocusedRowCellValue(colCode).ToString();
            }

            if (cusID == 0)
            {
                MessageBox.Show("Bạn hãy chọn một hãng để up datasheet!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            int            count = 0;
            OpenFileDialog ofd   = new OpenFileDialog();

            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (string filePath in ofd.FileNames)
                {
                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();
                    try
                    {
                        FileInfo          fInfo = new FileInfo(filePath);
                        MaterialFileModel fileModel;
                        bool isAdd = true;
                        if (MaterialFileBO.Instance.CheckExist("Name", Path.GetFileName(filePath)))
                        {
                            fileModel             = (MaterialFileModel)MaterialFileBO.Instance.FindByAttribute("Name", Path.GetFileName(filePath))[0];
                            isAdd                 = false;
                            fileModel.UpdatedDate = TextUtils.GetSystemDate();
                            fileModel.UpdatedBy   = Global.AppUserName;
                        }
                        else
                        {
                            fileModel             = new MaterialFileModel();
                            fileModel.CreatedDate = TextUtils.GetSystemDate();
                            fileModel.CreatedBy   = Global.AppUserName;
                            fileModel.UpdatedDate = fileModel.CreatedDate;
                            fileModel.UpdatedBy   = Global.AppUserName;
                        }

                        fileModel.Extension    = Path.GetExtension(filePath);
                        fileModel.Datemodified = fInfo.LastWriteTime;
                        fileModel.Length       = fInfo.Length;
                        fileModel.Name         = Path.GetFileName(fInfo.FullName);
                        fileModel.Path         = "Datasheet" + "/" + hang + "/" + Path.GetFileName(fInfo.FullName);
                        fileModel.IsDeleted    = false;
                        fileModel.FileType     = 1; //0 là file 3D cơ khí, 1 là datasheet
                        fileModel.CustormerID  = cusID;

                        if (isAdd)
                        {
                            pt.Insert(fileModel);
                        }
                        else
                        {
                            pt.Update(fileModel);
                        }

                        if (!DocUtils.CheckExits("Datasheet" + "/" + hang))
                        {
                            DocUtils.MakeDir("Datasheet" + "/" + hang);
                        }
                        DocUtils.UploadFile(filePath, "Datasheet" + "/" + hang);
                        pt.CommitTransaction();
                        count++;
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        pt.CloseConnection();
                    }
                }

                if (count > 0)
                {
                    loadGrid();
                }
            }
        }
示例#27
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (grvData.RowCount == 0)
            {
                return;
            }
            bool isSuccess = true;

            for (int i = 0; i < grvData.RowCount; i++)
            {
                string code = grvData.GetRowCellValue(i, colCode).ToString();
                if (code == "")
                {
                    continue;
                }
                string moduleFilm = grvData.GetRowCellValue(i, colFilm).ToString();
                if (ModulesBO.Instance.CheckExist("Code", code))
                {
                    if (moduleFilm != "" && code.ToUpper().StartsWith("TPAD"))
                    {
                        string[] listFilm = moduleFilm.Replace("\n", ",").Split(',');
                        foreach (string item in listFilm)
                        {
                            if (ModuleFilmBO.Instance.CheckExist("Code", code))
                            {
                                continue;
                            }
                            ModuleFilmModel fModel = new ModuleFilmModel();
                            fModel.LastTimeChange = 0;
                            fModel.LastDateChange = DateTime.Now;
                            fModel.Code           = item;
                            fModel.ModuleID       = ((ModulesModel)ModulesBO.Instance.FindByAttribute("Code", code)[0]).ID;
                            fModel.CreatedDate    = TextUtils.GetSystemDate();
                            fModel.CreatedBy      = Global.AppUserName;
                            fModel.UpdatedDate    = fModel.CreatedDate;
                            fModel.UpdatedBy      = Global.AppUserName;
                            ModuleFilmBO.Instance.Insert(fModel);
                        }
                    }
                    continue;
                }

                ModulesModel model = new ModulesModel();
                model.Code        = grvData.GetRowCellValue(i, colCode).ToString();
                model.Name        = grvData.GetRowCellValue(i, colName).ToString();
                model.Path        = "";
                model.Description = "";
                model.Note        = grvData.GetRowCellValue(i, colNote).ToString();

                model.Status         = TextUtils.ToInt(grvData.GetRowCellValue(i, colStatus1));
                model.FileElectric   = 0;
                model.FileElectronic = 0;
                model.FileMechanics  = 0;

                try
                {
                    ModuleGroupModel gmodel = new ModuleGroupModel();
                    if (code.ToUpper().StartsWith("TPAD"))
                    {
                        gmodel = (ModuleGroupModel)ModuleGroupBO.Instance.FindByAttribute("Code", code.Substring(0, 6))[0];
                    }
                    else if (code.ToUpper().StartsWith("PCB"))
                    {
                        gmodel = (ModuleGroupModel)ModuleGroupBO.Instance.FindByAttribute("Code", code.Substring(0, 5))[0];
                        model.FileElectronic = 1;
                        model.Status         = 0;
                    }
                    else
                    {
                        MessageBox.Show("Nhóm module này chưa được khởi tạo.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        isSuccess = false;
                        break;
                    }

                    model.ModuleGroupID = gmodel.ID;
                }
                catch (Exception)
                {
                    MessageBox.Show("Nhóm module này chưa được khởi tạo.", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    isSuccess = false;
                    break;
                }

                model.CreatedDate = TextUtils.GetSystemDate();
                model.CreatedBy   = Global.AppUserName;
                model.UpdatedDate = model.CreatedDate;
                model.UpdatedBy   = Global.AppUserName;
                model.ID          = (int)ModulesBO.Instance.Insert(model);

                if (moduleFilm != "" && code.ToUpper().StartsWith("TPAD"))
                {
                    string[] listFilm = moduleFilm.Replace("\n", ",").Split(',');
                    foreach (string item in listFilm)
                    {
                        ModuleFilmModel fModel = new ModuleFilmModel();
                        fModel.LastTimeChange = 0;
                        fModel.LastDateChange = DateTime.Now;
                        fModel.Code           = item;
                        fModel.ModuleID       = model.ID;
                        fModel.CreatedDate    = TextUtils.GetSystemDate();
                        fModel.CreatedBy      = Global.AppUserName;
                        fModel.UpdatedDate    = fModel.CreatedDate;
                        fModel.UpdatedBy      = Global.AppUserName;
                        ModuleFilmBO.Instance.Insert(fModel);
                    }
                }
            }
            if (isSuccess)
            {
                MessageBox.Show("Lưu trữ thành công", "Thông báo");
            }
        }
示例#28
0
        void save(bool close)
        {
            ProcessTransaction pt = new ProcessTransaction();

            pt.OpenConnection();
            pt.BeginTransaction();
            try
            {
                if (!ValidateForm())
                {
                    return;
                }

                grvFile.FocusedRowHandle = -1;

                #region Save Solution
                Solution.Name = txtName.Text.Trim().ToUpper();
                Solution.Code = txtCode.Text.Trim();
                Solution.RequireSolutionID = TextUtils.ToInt64(cboRequire.EditValue);

                Solution.Description          = txtDescription.Text;
                Solution.WorkDescription      = txtWorkDescription.Text;
                Solution.Version              = 1;
                Solution.Status               = cboStatus.SelectedIndex;
                Solution.NguoiPhuTrach        = TextUtils.ToInt(cboNguoiPhuTrach.EditValue);
                Solution.TotalCost            = TextUtils.ToDecimal(txtTotalCost.EditValue);
                Solution.Area                 = TextUtils.ToInt(cboArea.EditValue);
                Solution.SolutionTechnologyID = TextUtils.ToInt(cboTechnology.EditValue);
                Solution.StopReason           = txtReasonStop.Text;
                Solution.IsDeleted            = false;

                Solution.UpdatedDate = TextUtils.GetSystemDate();
                Solution.UpdatedBy   = Global.AppUserName;

                if (Solution.ID <= 0)
                {
                    Solution.CreatedDate = TextUtils.GetSystemDate();
                    Solution.CreatedBy   = Global.AppUserName;
                    Solution.ID          = (long)pt.Insert(Solution);
                }
                else
                {
                    pt.Update(Solution);
                }
                #endregion

                #region Save File
                DataRow[] drs = _dtFile.Select("ID = 0 or ID is null");
                if (drs.Length > 0)
                {
                    DocUtils.InitFTPTK();

                    using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang update tên cho file..."))
                    {
                        for (int i = 0; i < grvFile.RowCount; i++)
                        {
                            long id = TextUtils.ToInt64(grvFile.GetRowCellValue(i, colFileID));
                            if (id > 0)
                            {
                                SolutionFileModel fileModel = (SolutionFileModel)SolutionFileBO.Instance.FindByPK(id);
                                fileModel.Description = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileDescription));
                                pt.Update(fileModel);
                            }
                            else
                            {
                                string   name        = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileName));
                                string   extension   = Path.GetExtension(name);
                                decimal  length      = TextUtils.ToDecimal(grvFile.GetRowCellValue(i, colFileLenght));
                                string   description = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileDescription));
                                string   path        = "GiaiPhap/" + Solution.Code + "/" + name;
                                string   createdBy   = Global.AppUserName;
                                DateTime?createdDate = DateTime.Now;

                                string localPath = TextUtils.ToString(grvFile.GetRowCellValue(i, colFileLocalPath));

                                if (!DocUtils.CheckExits("GiaiPhap/" + Solution.Code))
                                {
                                    DocUtils.MakeDir("GiaiPhap/" + Solution.Code);
                                }

                                SolutionFileModel fileModel = new SolutionFileModel();
                                fileModel.CreatedBy          = createdBy;
                                fileModel.CreatedDate        = createdDate;
                                fileModel.Description        = description;
                                fileModel.Extension          = extension;
                                fileModel.Length             = length;
                                fileModel.Name               = name;
                                fileModel.Path               = path;
                                fileModel.SolutionID         = Solution.ID;
                                fileModel.SolutionFileTypeID = TextUtils.ToInt(grvGroupFile.GetFocusedRowCellValue(colGFID));
                                pt.Insert(fileModel);

                                DocUtils.UploadFile(localPath, "GiaiPhap/" + Solution.Code);
                            }
                        }
                    }
                }
                #endregion

                #region Save DMVT
                for (int i = 0; i < grvVT.RowCount; i++)
                {
                    long id = TextUtils.ToInt64(grvVT.GetRowCellValue(i, colMaID));
                    SolutionItemModel item = new SolutionItemModel();
                    if (id > 0)
                    {
                        item = (SolutionItemModel)SolutionItemBO.Instance.FindByPK(id);
                    }

                    item.Code       = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaCode));
                    item.Name       = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaName));
                    item.Hang       = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaHang));
                    item.Qty        = TextUtils.ToDecimal(grvVT.GetRowCellValue(i, colMaQty));
                    item.Price      = TextUtils.ToDecimal(grvVT.GetRowCellValue(i, colMaPrice));
                    item.TotalPrice = TextUtils.ToDecimal(grvVT.GetRowCellValue(i, colMaTotalPrice));
                    item.QtyError   = TextUtils.ToInt(grvVT.GetRowCellValue(i, colMaError));
                    item.QtyKPH     = TextUtils.ToInt(grvVT.GetRowCellValue(i, colMaKPH));
                    item.QtyTon     = TextUtils.ToInt(grvVT.GetRowCellValue(i, colMaTonKho));

                    //item.Unit = TextUtils.ToString(grvVT.GetRowCellValue(i, colMau));
                    //item.Status = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaCode));
                    //item.Type = TextUtils.ToString(grvVT.GetRowCellValue(i, colMaCode));

                    item.SolutionID = Solution.ID;
                    if (id > 0)
                    {
                        pt.Update(item);
                    }
                    else
                    {
                        pt.Insert(item);
                    }
                }
                #endregion

                pt.CommitTransaction();

                loadFile();
                loadDMVT();
                _isSaved = true;

                if (close)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Lưu trữ thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lưu trữ không thành công!" + Environment.NewLine + ex.Message, TextUtils.Caption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                pt.CloseConnection();
            }
        }
示例#29
0
        private void btnAddFile_Click(object sender, EventArgs e)
        {
            //KcsError
            string criteriaImportId = TextUtils.ToString(grvData.GetFocusedRowCellValue(colCriteriaImportId));

            //string orderCode = TextUtils.ToString(grvOrder.GetFocusedRowCellValue(colSoDonHang));

            if (criteriaImportId == "")
            {
                return;
            }

            DocUtils.InitFTPTK();

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Multiselect = true;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                foreach (string filePath in ofd.FileNames)
                {
                    FileInfo fInfo = new FileInfo(filePath);

                    ProcessTransaction pt = new ProcessTransaction();
                    pt.OpenConnection();
                    pt.BeginTransaction();

                    try
                    {
                        CriteriaImportImageModel model = new CriteriaImportImageModel();
                        model.CriteriaImportId = criteriaImportId;
                        model.FileName         = fInfo.Name;
                        //model.FileLocalPath = fInfo.FullName;
                        model.FilePath    = "KcsError\\" + criteriaImportId + "\\" + fInfo.Name;
                        model.Size        = fInfo.Length;
                        model.DateCreated = TextUtils.GetSystemDate();
                        pt.Insert(model);
                        if (!DocUtils.CheckExits("KcsError\\" + criteriaImportId + "\\"))
                        {
                            DocUtils.MakeDir("KcsError\\" + criteriaImportId + "\\");
                        }
                        bool status = DocUtils.UploadFileWithStatus(filePath, "KcsError\\" + criteriaImportId);
                        if (status)
                        {
                            pt.CommitTransaction();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        pt.CloseConnection();
                    }
                }

                loadImge(criteriaImportId);
            }
        }
示例#30
0
        void addFile(bool allFile)
        {
            DocUtils.InitFTPTK();
            OpenFileDialog ofd = new OpenFileDialog();

            if (!allFile)
            {
                ofd.Filter = "Image files (*.jpg, *.jpeg, *.png,*.gif) | *.jpg; *.jpeg; *.png; *.gif";
            }
            ofd.Multiselect = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang up file lên server!"))
                {
                    foreach (string filePath in ofd.FileNames)
                    {
                        ProcessTransaction pt = new ProcessTransaction();
                        pt.OpenConnection();
                        pt.BeginTransaction();
                        try
                        {
                            ProjectProblemImageModel problemImageModel;
                            bool isAdd = true;
                            if (!ProjectProblemImageBO.Instance.CheckExist("FileName", Path.GetFileName(filePath)))
                            {
                                problemImageModel = new ProjectProblemImageModel();
                            }
                            else
                            {
                                problemImageModel = (ProjectProblemImageModel)ProjectProblemImageBO.Instance.FindByAttribute("FileName", Path.GetFileName(filePath))[0];
                                isAdd             = false;
                            }

                            FileInfo fInfo = new FileInfo(filePath);

                            string ftpFolderPath = "ProjectProblem\\" + ProjectProblem.ID;

                            problemImageModel.DateCreated      = TextUtils.GetSystemDate();
                            problemImageModel.FileName         = Path.GetFileName(filePath);
                            problemImageModel.Size             = fInfo.Length;
                            problemImageModel.FilePath         = ftpFolderPath + "\\" + problemImageModel.FileName;
                            problemImageModel.ProjectProblemID = ProjectProblem.ID;

                            if (isAdd)
                            {
                                problemImageModel.ID = (int)pt.Insert(problemImageModel);
                            }
                            else
                            {
                                pt.Update(problemImageModel);
                            }

                            if (!DocUtils.CheckExits(ftpFolderPath))
                            {
                                DocUtils.MakeDir(ftpFolderPath);
                            }
                            DocUtils.UploadFile(filePath, ftpFolderPath);

                            pt.CommitTransaction();
                        }
                        catch (Exception)
                        {
                        }
                        finally
                        {
                            pt.CloseConnection();
                        }
                    }

                    loadImage();
                }
            }
        }