private void btnDelete_Click(object sender, EventArgs e) { try { if (grvDatasheet.RowCount <= 0) { return; } if (MessageBox.Show("Bạn có thật sự muốn xóa file này không?", TextUtils.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } int linkID = TextUtils.ToInt(grvDatasheet.GetFocusedRowCellValue(colIDdatasheet)); MaterialFileLinkBO.Instance.Delete(linkID); Material.FileDatasheet = 0; MaterialBO.Instance.Update(Material); loadDatasheet(); } catch (Exception ex) { TextUtils.ShowError(ex.Message); } }
private void frmFile3DGroupcs_Load(object sender, EventArgs e) { try { DataTable dt = TextUtils.Select("ConfigSystem", new Expression("KeyName", "3D")); DPath = dt.Rows[0][2].ToString(); Directory.CreateDirectory(DPath); loadCombo(ParentID); cboParent.SelectedValue = ParentID; cboParent.Enabled = false; if (Model.ID != 0) { txtName.Text = Model.Name; _currentPath = Model.Path; } else { if (ParentID != 0) { DPath = ((ProductGroupModel)ProductGroupBO.Instance.FindByPK(ParentID)).Path; } } } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void diChuyênToolStripMenuItem_Click(object sender, EventArgs e) { string parent = treeList1.FocusedNode.GetValue(colTreeParentID).ToString(); if (parent != "0") { MessageBox.Show("Bạn hãy chọn đúng đường dẫn cần di chuyển tới"); return; } try { string selectedFolderPath = treeList1.FocusedNode.GetValue(colTreeFilelPath).ToString(); string selectedFileName = grvScan.GetFocusedRowCellValue(colFilePath).ToString(); string destFileName = selectedFolderPath + "\\" + Path.GetFileName(selectedFileName); if (File.Exists(destFileName)) { File.Delete(destFileName); } File.Move(selectedFileName, destFileName); btnRefresh_Click(null, null); } catch (Exception ex) { TextUtils.ShowError(ex); return; } }
void CreateProduct() { for (int i = 0; i < grvData.RowCount; i++) { try { string code = grvData.GetRowCellValue(i, "F2").ToString(); if (code == "") { continue; } DataTable dt = TextUtils.Select("select * from Products with(nolock) where Code = '" + code + "'"); if (dt.Rows.Count > 0) { continue; } string groupCode = code.Split('.')[0]; ProductGroupModel group = (ProductGroupModel)ProductGroupBO.Instance.FindByAttribute("Code", groupCode)[0]; string name = grvData.GetRowCellValue(i, "F1").ToString(); ProductsModel product = new ProductsModel(); product.ProductGroupID = group.ID; product.Code = code; product.Name = name; ProductsBO.Instance.Insert(product); } catch (Exception ex) { TextUtils.ShowError(ex); } } }
void loadGrid(bool isFilterGroup) { try { int groupID = 0; if (isFilterGroup) { groupID = TextUtils.ToInt(treeData.FocusedNode.GetValue(colIDTree)); } string[] paraName = new string[3]; object[] paraValue = new object[3]; paraName[0] = "@Code"; paraValue[0] = txtCode.Text.Trim(); paraName[1] = "@Name"; paraValue[1] = txtName.Text.Trim(); paraName[2] = "@GroupID"; paraValue[2] = groupID; DataTable Source = ProductsBO.Instance.LoadDataFromSP("spGetFilterProduct", "Source", paraName, paraValue); grdData.DataSource = Source; if (_rownIndex >= grvData.RowCount) { _rownIndex = 0; } if (_rownIndex > 0) { grvData.FocusedRowHandle = _rownIndex; } grvData.SelectRow(_rownIndex); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void btnDownload_Click(object sender, EventArgs e) { using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang download file!")) { try { string path = @"Thietke.Ck\\" + ModuleCode.Substring(0, 6) + "\\" + ModuleCode + ".Ck\\MAT." + ModuleCode; string localPath = "D:\\" + path; if (!DocUtils.CheckExits(path)) { MessageBox.Show("Không tồn tại thư mục MAT." + ModuleCode + " trên nguồn thiết kế!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } Directory.CreateDirectory(localPath); string[] listFilm = DocUtils.GetContentList(path); foreach (string fileName in listFilm) { try { DocUtils.DownloadFile(localPath, fileName, path + "\\" + fileName); Process.Start(localPath + "\\" + fileName); } catch (Exception) { } } } catch (Exception ex) { TextUtils.ShowError("Download file không thành công!" + Environment.NewLine + ex.ToString()); } } }
void loadData() { if (txtEndDate.Text == "" || txtStartDate.Text == "") { MessageBox.Show("Hãy chọn một tuần trong năm!", TextUtils.Caption); return; } grdData.DataSource = null; try { string[] paraName = new string[2]; object[] paraValue = new object[2]; paraName[0] = "@FromDate"; paraValue[0] = TextUtils.ToDate(txtStartDate.Text).ToString("yyyy/MM/dd"); paraName[1] = "@ToDate"; paraValue[1] = TextUtils.ToDate(txtEndDate.Text).ToString("yyyy/MM/dd"); DataTable Source = WorksBO.Instance.LoadDataFromSP("spGetAllTimeOfUserInWeek", "Source", paraName, paraValue); grdData.DataSource = Source; } catch (Exception ex) { TextUtils.ShowError(ex); } }
void loadMaterial() { try { int groupID = TextUtils.ToInt(cboMaterialGroup.EditValue); if (groupID == 0) { return; } DataTable dt = TextUtils.Select("Select Name from MaterialParameters with(nolock) where MaterialGroupID= " + groupID + " order by STT"); if (dt.Rows.Count == 0) { TextUtils.ShowError("Nhóm vật tư này chưa có thông số!"); grdData.DataSource = null; return; } string listPara = ""; foreach (DataRow item in dt.Rows) { listPara += "[" + item[0] + "]" + ","; } listPara = listPara.Substring(0, listPara.Length - 1); paraName[0] = "@MaterialGroupID"; paraValue[0] = groupID.ToString(); paraName[1] = "@ListParams"; paraValue[1] = listPara; dtAllMaterial = MaterialBO.Instance.LoadDataFromSP("spMaterialAndPara", "Source", paraName, paraValue); dtAllMaterial.Columns[0].Caption = "ID"; dtAllMaterial.Columns[1].Caption = "Mã"; dtAllMaterial.Columns[2].Caption = "Tên"; dtAllMaterial.Columns[3].Caption = "Hãng"; dtAllMaterial.Columns[4].Caption = "Giá(VNĐ)"; dtAllMaterial.Columns[5].Caption = "Thời gian GH(Ngày)"; dtAllMaterial.Columns[6].Caption = "Ngày GD gần nhất"; grvData.PopulateColumns(dtAllMaterial); grdData.DataSource = dtAllMaterial; grvData.Columns[6].DisplayFormat.FormatType = FormatType.DateTime; grvData.Columns[6].DisplayFormat.FormatString = "dd/MM/yyyy"; //grvData.Columns[6].AppearanceCell.HAlignment = DevExpress.Utils.HorzAlignment.Center; grvData.Columns[4].DisplayFormat.FormatType = FormatType.Numeric; grvData.Columns[4].DisplayFormat.FormatString = "{0:#,##0.####}"; grvData.Columns[0].Visible = false; grvData.Columns[7].Visible = false; grvData.Columns[8].Visible = false; grvData.BestFitColumns(); } catch (Exception ex) { } finally { grdOne.DataSource = null; } }
private void grvData_DoubleClick(object sender, EventArgs e) { try { string fileName = grvData.GetFocusedRowCellValue(colName).ToString().Replace("code", ProductCode); string temFolder = grvData.GetFocusedRowCellValue(colPathFolderC).ToString().Replace("code", ProductCode); string destFileName = ""; if (TemplateType == 1)//cơ khí { destFileName = @"D:\Thietke.Ck\TPAD." + ProductCode.Substring(5, 1) + "\\" + temFolder + "\\" + fileName + Path.GetExtension(SelectedFilePath); } if (TemplateType == 3)//điện tử { destFileName = @"D:\Thietke.Dt\PCB." + ProductCode.Substring(4, 1) + "\\" + temFolder + "\\" + fileName + ".pdf"; } if (File.Exists(destFileName)) { File.Delete(destFileName); } File.Move(SelectedFilePath, destFileName); } catch (Exception ex) { TextUtils.ShowError(ex); return; } DialogResult = DialogResult.OK; }
private void repositoryItemHyperLinkEdit1_Click_1(object sender, EventArgs e) { try { string action = grvData.GetFocusedRowCellValue(colAction).ToString(); string path = ""; File3DModel model = (File3DModel)File3DBO.Instance.FindByPK(ID); DateTime date = TextUtils.ToDate(grvData.GetFocusedRowCellValue(colDate).ToString()); if (action == "Thêm mới") { path = model.Path; } else { path = model.Path.Replace(model.Name, date.ToString("dd-MM-yyyy") + @"\" + model.Name).Trim(); } FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Chọn nơi lưu trữ"; if (fbd.ShowDialog() == DialogResult.OK) { _hu = fbd.SelectedPath + @"\" + Path.GetFileName(path); File.Copy(path, _hu, true); MessageBox.Show("Tải file xuống thành công!"); } } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void btnSave_Click(object sender, EventArgs e) { ProcessTransaction pt = new ProcessTransaction(); pt.OpenConnection(); pt.BeginTransaction(); try { if (!checkValid()) { return; } ModuleErrorTypeModel model; if (_isAdd) { model = new ModuleErrorTypeModel(); } else { model = (ModuleErrorTypeModel)ModuleErrorTypeBO.Instance.FindByPK(_id); } //model.Type = cboType.SelectedIndex; model.Type = 0; model.Name = txtName.Text.Trim(); model.GroupID = (int)cboGroup.SelectedValue; if (_isAdd) { pt.Insert(model); } else { pt.Update(model); } pt.CommitTransaction(); if (model.GroupID == 0) { loadGroup(); } loadTree(); SetInterface(false); ClearInterface(); _isSaved = true; } catch (Exception ex) { TextUtils.ShowError("Lưu trữ không thành công!", ex); } finally { pt.CloseConnection(); } }
private void btnSave_Click(object sender, EventArgs e) { try { if (!validateForm()) { return; } string productCode = txtModel.Text.ToUpper(); using (WaitDialogForm fWait = new WaitDialogForm("Vui lòng chờ trong giây lát...", "Đang tạo cây thư mục...")) { if (Directory.Exists(@"D:\")) { _initPath = "D:\\Thietke.Gp\\"; Directory.CreateDirectory(_initPath); } else { if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { _initPath = folderBrowserDialog1.SelectedPath; } else { return; } } ArrayList list = DesignStructureBO.Instance.FindByAttribute("Type", 3); for (int i = 0; i < list.Count; i++) { DesignStructureModel model = (DesignStructureModel)list[i]; string directtion = ""; if (model.Path.Contains("code")) { directtion = (_initPath + @"\" + model.Path).Replace("code", productCode); } else { directtion = (_initPath + @"\" + model.Path); } if (i == 0) { _duongDanChinh = directtion; } Directory.CreateDirectory(directtion); } } MessageBox.Show("Tạo cấu trúc thiết kế thành công!", TextUtils.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); Process.Start(_duongDanChinh); } catch (System.Exception ex) { TextUtils.ShowError(ex); } }
private void btnConfirm_Click(object sender, EventArgs e) { if (txtReason.Text.Trim() == "") { TextUtils.ShowError("Bạn phải điền nguyên nhân tạo phiên bản"); return; } Reason = txtReason.Text.Trim(); DialogResult = DialogResult.OK; }
private void frmProjectStatus_Load(object sender, EventArgs e) { try { LoadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmWorkingDiariesLocation_Load(object sender, EventArgs e) { try { loadGrid(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void btnImport_Click(object sender, EventArgs e) { try { DataTable dt = new DataTable(); OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { dt = TextUtils.ExcelToDatatable(ofd.FileName); } if (dt.Rows.Count <= 0) { return; } if (dt.Rows[6][2].ToString() == "") { return; //check mã dự án } txtProjectCode.Text = dt.Rows[6][2].ToString(); txtProjectName.Text = dt.Rows[6][5].ToString(); txtContractCode.Text = dt.Rows[7][2].ToString(); txtContractName.Text = txtContractCode.Text.Trim() != "" ? "Hợp đồng kinh tế số " + dt.Rows[7][2].ToString() : ""; txtCurator.Text = dt.Rows[5][5].ToString(); txtCustomerName.Text = dt.Rows[9][2].ToString(); txtLastCustomerName.Text = dt.Rows[9][5].ToString(); txtReception.Text = dt.Rows[8][5].ToString(); txtRequirement.Text = dt.Rows[8][2].ToString(); txtPriority.Text = dt.Rows[5][2].ToString(); cboStatus.SelectedIndex = 0; for (int i = 13; i < dt.Rows.Count; i++) { if (dt.Rows[i][3].ToString() == "" || dt.Rows[i][1].ToString() == "") { continue; } ProductsModel model = new ProductsModel(); model.PjCode = dt.Rows[i][3].ToString(); model.PjName = dt.Rows[i][1].ToString(); model.Quantity = TextUtils.ToInt(dt.Rows[i][5]); model.Unit = dt.Rows[i][4].ToString(); _listProducts.Add(model); } } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmConfigTimeProjectDirectionType_Load(object sender, EventArgs e) { try { loadParent(); LoadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmDepartment_Load(object sender, EventArgs e) { try { loadCombo(); LoadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmDepartmentQLSX_Load(object sender, EventArgs e) { try { loadLeader(); loadGrid(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmCauHinhCTTK_Load(object sender, EventArgs e) { try { ConfigSystemModel model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "CTTK")[0]; mmeText.Text = model.KeyValue; _ID = TextUtils.ToInt(model.ID); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmStaffGroup_Load(object sender, EventArgs e) { try { loadCombo(); loadLeader(); LoadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmCustomer_Load(object sender, EventArgs e) { try { loadCombo(); LoadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } DocUtils.InitFTPTK(); }
private void frmListDesigner_Load(object sender, EventArgs e) { this.Text += ": " + Code + " - " + Name; try { loadCombo(); LoadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void frmUserGroupQLSX_Load(object sender, EventArgs e) { try { loadDepartment(); loadLeader(); loadData(); } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void btnImport_Click(object sender, EventArgs e) { try { string FileName = Application.StartupPath + "\\Templates\\ImportSP.xlsx"; Process.Start(FileName); if (MessageBox.Show("Bạn đã lưu lại file Excel chưa?\n Sẵn sàng Import vào phần mềm!", "Xác nhận", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { btnNew_Click(null, null); btnSave.Visible = true; DataTable dt = TextUtils.ExcelToDatatable(FileName, "SanPhamDA"); if (dt.Rows.Count <= 0) { return; } dt.Columns[0].ColumnName = "TenTheoHopDong"; dt.Columns[1].ColumnName = "MaTheoHopDong"; dt.Columns[2].ColumnName = "SL"; if (dt.Rows.Count > 0) { IEnumerable <DataRow> dr = (from order in dt.AsEnumerable() where order.Field <string>("TenTheoHopDong") != "" && order.Field <string>("TenTheoHopDong") != null select order); if (dr.Count() > 0) { dt = dr.CopyToDataTable(); } else { dt = new DataTable(); } //.CopyToDataTable(); } DataTable dtt = m_DataSource; foreach (DataRow item in dt.Rows) { dtt.ImportRow(item); } grdData.DataSource = dtt; grvData.BestFitColumns(); grdData.Focus(); } } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void cboMaterialGroupN_EditValueChanged(object sender, EventArgs e) { try { if (cboMaterialGroupN.EditValue != null) { loadGridParasN(); } } catch (Exception ex) { TextUtils.ShowError(ex); } }
private void cboSheet_SelectionChangeCommitted(object sender, EventArgs e) { try { _dtData = TextUtils.ExcelToDatatableNoHeader(btnBrowse.Text, cboSheet.SelectedValue.ToString()); _dtData.Columns.Add("ID", typeof(int)); _dtData.Rows.RemoveAt(0); grdData.DataSource = _dtData; } catch (Exception ex) { TextUtils.ShowError(ex); grdData.DataSource = null; } }
private void cboSheet_SelectionChangeCommitted(object sender, EventArgs e) { grvData.Columns.Clear(); if (chkAutoCheck.Checked) { try { DataTable dtt = ds.Tables[cboSheet.SelectedIndex]; for (int i = 0; i < dtt.Columns.Count; i++) { dtt.Columns[i].ColumnName = "F" + i.ToString(); } grdData.DataSource = dtt; grvData.PopulateColumns(); // Tao cot cho cac truong trong datatable //grvData.BestFitColumns(); // Tu dong dieu chinh kich thuoc cot -- Ton nhieu tg grvData.Focus(); for (int i = 0; i < dtt.Columns.Count; i++) { grvData.Columns[i].Caption = "F" + i.ToString(); //dtt.Columns[i].ColumnName = "F" + i.ToString(); } var test = grvData.Columns; } catch (Exception er) { TextUtils.ShowError(er); grdData.DataSource = null; } } else { try { DataTable dt = TextUtils.ExcelToDatatableNoHeader(btnBrowse.Text, cboSheet.SelectedValue.ToString()); grdData.DataSource = dt; grvData.PopulateColumns(); // Tao cot cho cac truong trong datatable //grvData.BestFitColumns(); // Tu dong dieu chinh kich thuoc cot -- Ton nhieu tg grvData.Focus(); } catch (Exception er) { TextUtils.ShowError(er); grdData.DataSource = null; } } }
private void cboSheet_SelectionChangeCommitted(object sender, EventArgs e) { try { DataTable dt = TextUtils.ExcelToDatatableNoHeader(btnBrowse.Text, cboSheet.SelectedValue.ToString()); grdData.DataSource = dt; grvData.PopulateColumns(); grvData.BestFitColumns(); } catch (Exception ex) { TextUtils.ShowError(ex); grdData.DataSource = null; } }
private void btnNewGroup_Click(object sender, EventArgs e) { try { ConfigSystemModel model = new ConfigSystemModel(); model.KeyValue = mmeText.Text; model.KeyName = "CTTK"; model.ID = _ID; ConfigSystemBO.Instance.Update(model); MessageBox.Show("OK"); this.Close(); } catch (Exception ex) { TextUtils.ShowError(ex); } }