decimal countPart() { ConfigSystemModel model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "CanhBaoHanVeVT_period")[0]; string sqlPart = "SELECT * FROM [vRequireBuyPart] with(nolock) where (status = 2) and [DateAboutE] is not null and ([DateAboutF] is null or [DateAboutF] = '')" + " and datediff(dd,getdate(),DateAboutE)<= " + model.KeyValue + " and Account = '" + Global.AppUserName + "'"; DataTable dtData = LibQLSX.Select(sqlPart); string sqlOut = "SELECT * FROM [vRequestOut] with(nolock) where ([ProposalStatus] = 2) and [DateAboutE] is not null and ([DateAboutF] is null or [DateAboutF] = '')" + " and datediff(dd,getdate(),DateAboutE)<= " + model.KeyValue + " and Account = '" + Global.AppUserName + "'"; DataTable dtOut = LibQLSX.Select(sqlOut); string sqlMaterial = "SELECT * FROM [vRequestMaterial] with(nolock) where ([ProposalStatus] = 2) and [DateAboutE] is not null and ([DateAboutF] is null or [DateAboutF] = '')" + " and datediff(dd,getdate(),DateAboutE) <= " + model.KeyValue + " and Account = '" + Global.AppUserName + "'"; DataTable dtMaterial = LibQLSX.Select(sqlMaterial); if (dtMaterial.Rows.Count > 0) { dtData.Merge(dtMaterial); } if (dtOut.Rows.Count > 0) { dtData.Merge(dtOut); } return(dtData.Rows.Count); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region Cac ham xu li khac /// <summary> /// Lấy giá trị trong bảng ConfigSystem /// </summary> /// <param name="keyName">trường đại diện của giá trị</param> /// <returns></returns> public static string[] GetConfigSystem(string keyName) { ConfigSystemModel config = new ConfigSystemModel(); ArrayList arr = ConfigSystemBO.Instance.FindByAttribute("KeyName", keyName); if (arr.Count == 0) { throw new Exception(String.Format("[{0}] does not exist in [ConfigSystem].", keyName)); } else { config = (ConfigSystemModel)arr[0]; } List <string> vals = new List <string>(); PropertyInfo[] props = config.GetType().GetProperties(); foreach (PropertyInfo p in props) { if (p.Name.StartsWith("KeyValue")) { vals.Add(p.GetValue(config, null).ToString()); } } return(vals.ToArray()); }
private void timer1_Tick(object sender, EventArgs e) { try { if (Global.DepartmentID == 6) { ConfigSystemModel model = (ConfigSystemModel)ConfigSystemBO.Instance. FindByAttribute("KeyName", "CanhBaoHanVeVT")[0]; List <string> listTime = model.KeyValue.Split(',').ToList(); string now = DateTime.Now.ToString("HH:mm:ss"); if (listTime.Contains(now)) { decimal countVT = countPart(); decimal countYC = countYCMVT(); if (countVT > 0) { showPopUp("Có " + countVT + " vật tư sắp đến ngày về.", 0); } if (countYC > 0) { showPopUp("Có " + countYC + " YCMVT đã quá hạn mà chưa tạo PO.", 1); } } } } catch { } }
private void timer1_Tick(object sender, EventArgs e) { //WarningWork try { ConfigSystemModel model = (ConfigSystemModel)ConfigSystemBO.Instance. FindByAttribute("KeyName", "WarningWork")[0]; List <string> listTime = model.KeyValue.Split(',').ToList(); string now = DateTime.Now.ToString("HH:mm:ss"); if (listTime.Contains(now)) { DataRow[] drs = _dtData.Select("Status = 0 and UserID = " + Global.UserID); DataRow[] drs1 = _dtData.Select("Status = 0 and ChenhLech <= 0 and UserID = " + Global.UserID); if (drs.Length > 0) { if (drs1.Length > 0) { showPopUp("Có " + drs.Length + " công việc chưa hoàn thành.\n" + "Có " + drs1.Length + " công việc quá hạn"); } else { showPopUp("Có " + drs.Length + " công việc chưa hoàn thành."); } } } } catch (Exception) { } }
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); } }
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); } }
/// <summary> /// Lấy đường dẫn thư mục trên Server /// </summary> /// <param name="pathServerNotDrive"></param> /// <returns></returns> public static string GetPathServer() { string pathServer = ""; try { ConfigSystemModel model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "UpdatePath")[0]; pathServer = @"" + model.KeyValue; } catch { } return(pathServer); }
private void btnEdit_Click(object sender, EventArgs e) { if (!grvData.IsDataRow(grvData.FocusedRowHandle)) { return; } SetInterface(true); int i = TextUtils.ToInt(grvData.GetFocusedRowCellValue(colID).ToString()); _model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByPK(i); txtKey.Text = grvData.GetFocusedRowCellValue(colKeyName).ToString(); txtDuongDan.Text = grvData.GetFocusedRowCellValue(colKeyValue).ToString(); txtMoTa.Text = grvData.GetFocusedRowCellValue(colDescription).ToString(); isAdd = false; }
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); } }
private void timer1_Tick(object sender, EventArgs e) { try { ConfigSystemModel model = (ConfigSystemModel)ConfigSystemBO.Instance.FindByAttribute("KeyName", "SetTimeTheoDoi")[0]; TimeSet = model.KeyValue.Split(','); for (int i = 0; i < TimeSet.Count(); i++) { string time = Convert.ToDateTime(TimeSet[i]).ToString("t"); if (DateTime.Now.ToString("t") == time) { View_popup(); } } if (DateTime.Now.ToString("t") == Convert.ToDateTime("16:40").ToString("t")) { //View_NhatKy(); } } catch (Exception) { } }
protected ConfigSystemFacade(ConfigSystemModel model) : base(model) { }
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(); } } }