/// <summary> /// Load data /// </summary> private void LoadData() { BD_SuppliesData data = new BD_SuppliesData(); ITransaction tran = factory.GetLoadObject(data, id); Execute(tran); if (!HasError) { //Get Data data = (BD_SuppliesData)tran.Result; lblCreatedId.Text = data.CreatedId; lblName.Text = data.Name; } ShowData(); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAutoId_Click(object sender, EventArgs e) { BD_SuppliesData data = new BD_SuppliesData(); string prefix = Func.ParseString(Session["__BUILDINGID__"]) + DbHelper.GetScalar("Select Comment From Mst_SuppliesType Where id = '" + hidSuppliesType.Value + "'"); if (String.IsNullOrEmpty(prefix)) { mvMessage.AddError("Lỗi xảy ra, hãy bấm F5 hoặc liên hệ Admin"); return; } int length = 10; string tmp = String.Format("", length); string sql = "SELECT max(maxid) from (SELECT SUBSTRING(CreatedId, " + (prefix.Length + 1) + ", " + length + ") as maxid FROM BD_Supplies) as tmp WHERE maxid < '100'"; int key = 0; try { key = Convert.ToInt32(DbHelper.GetScalar(sql)); key++; } catch { key = 1; } bool keyFlg = true; while (keyFlg) { string tmpKey = prefix + key.ToString().PadLeft(length - prefix.Length, '0'); sql = "SELECT count(*) from BD_Supplies WHERE CreatedId = '" + tmpKey + "'"; if (Convert.ToInt32(DbHelper.GetScalar(sql)) != 1) { keyFlg = false; } else { key--; } } txtAutoId.Text = prefix + key.ToString().PadLeft(length - prefix.Length, '0'); }
/// <summary> /// Update /// </summary> private void UpdateData() { BD_SuppliesData data = new BD_SuppliesData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (BD_SuppliesData)tran.Result; data.Name = txtName.Text.Trim(); data.Description = txtDescription.Text.Trim(); data.Comment = txtComment.Text.Trim(); //data.Type = txtType.Text.Trim(); data.ProductOf = txtProductOf.Text.Trim(); data.ModifiedBy = Page.User.Identity.Name; data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); data.DelFlag = true.Equals(chkDelFlag.Checked) ? "0" : "1"; data.Model = txtModel.Text; data.Label = txtLabel.Text; data.Regional = txtRegional.Text; tran = factory.GetUpdateObject(data); Execute(tran); if (!HasError) { OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateSuccess, Page.User.Identity.Name); mvMessage.SetCompleteMessage(updateSuccess); ScriptManager.RegisterClientScriptBlock(this.btnRegister, this.GetType(), key, postback, true); lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); mvMessage.AddError(updateUnSuccess); } } }
/// <summary> /// Load data /// </summary> private void LoadData() { BD_SuppliesData data = new BD_SuppliesData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (BD_SuppliesData)tran.Result; txtId.Text = data.CreatedId; txtName.Text = data.Name; txtDescription.Text = data.Description; txtProductOf.Text = data.ProductOf; txtComment.Text = data.Comment; txtModel.Text = data.Model; txtLabel.Text = data.Label; txtRegional.Text = data.Regional; chkDelFlag.Checked = "1".Equals(data.DelFlag) ? false : true; lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; hidId.Value = id; switch (data.SuppliesType) { case "1": lblHeader.Text = "Quản lý vật tư – Thiết bị VP"; lblDescription.Text = "Mô Tả"; lblRegional.Text = "Khu vực sử dụng"; lblModel.Text = "Mã hàng"; break; case "2": lblHeader.Text = "Quản lý hoạt động > Thiết bị > Danh sách"; break; case "3": lblHeader.Text = "Quản lý tài chính > Vật tư tiêu hao"; lblDescription.Text = "Mô Tả"; lblRegional.Text = "Khu vực sử dụng"; lblModel.Text = "Mã hàng"; break; case "4": lblHeader.Text = "Kế toán > Quản lý vật tư - dụng cụ KT"; break; case "5": lblHeader.Text = "Quản lý kỹ thuật > Quản lý vật tư - dụng cụ KT"; break; case "6": lblHeader.Text = "Quản lý kỹ thuật > Hệ thống kỹ thuật tòa nhà"; break; } } }
/// <summary> /// Insert data /// </summary> private void InsertData() { //Get and Insert Data BD_SuppliesData data = new BD_SuppliesData(); ITransaction tran = factory.GetInsertObject(data); data.CreatedId = txtId.Text.Trim(); data.JobType = null; data.SuppliesType = hidSuppliesType.Value; data.ItemId = null; data.Name = txtName.Text.Trim(); data.Description = txtDescription.Text.Trim(); data.ProductOf = txtProductOf.Text.Trim(); data.ModifiedBy = Page.User.Identity.Name; data.CreatedBy = Page.User.Identity.Name; data.Created = DateTime.Now.ToString("yyyyMMddHHmmss"); data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); data.DelFlag = true.Equals(chkDelFlag.Checked) ? "0" : "1"; data.Model = txtModel.Text; data.Label = txtLabel.Text; data.Regional = txtRegional.Text; //data.SuppliesId = txtId.Text.Trim(); data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]); Execute(tran); if (!HasError) { OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name); mvMessage.SetCompleteMessage(addSuccess); ScriptManager.RegisterClientScriptBlock(this.btnRegister, this.GetType(), key, postback, true); btnRegister.CommandName = "Register"; hidId.Value = data.id; hidAction.Value = "Edit"; txtId.Enabled = false; lblCreated.Text = !"".Equals(data.Created) ? data.CreatedBy + "(" + Func.Formatdmyhms(data.Created) + ")" : ""; lblModified.Text = !"".Equals(data.Modified) ? data.ModifiedBy + "(" + Func.Formatdmyhms(data.Modified) + ")" : ""; } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name); mvMessage.AddError(addUnSuccess); } }
protected void Page_Load(object sender, EventArgs e) { hidSuppliesType.Value = Func.ParseString(Request["SuppliesType"]); hidId.Value = Func.ParseString(Request["id"]); switch (hidSuppliesType.Value) { case "1": ltrPage.Text = "Quản lý hoạt động > Vật tư > Bảo trì"; break; case "2": ltrPage.Text = "Quản lý hoạt động > Thiết bị > Bảo trì"; break; case "3": ltrPage.Text = "Kế toán > Vật tư > Bảo trì"; break; case "4": ltrPage.Text = "Kế toán > Thiết bị > Bảo trì"; break; case "5": ltrPage.Text = "Kỹ thuật > Vật tư > Bảo trì"; break; case "6": ltrPage.Text = "Kỹ thuật > Thiết bị > Bảo trì"; break; } if (!IsPostBack) { PopupWidth = 600; PopupHeight = 450; ShowData(); BD_SuppliesData data = new BD_SuppliesData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (BD_SuppliesData)tran.Result; txtId.Text = data.CreatedId; txtName.Text = data.Name; txtDescription.Text = data.Description; txtProductOf.Text = data.ProductOf; txtComment.Text = data.Comment; txtModel.Text = data.Model; txtLabel.Text = data.Label; txtRegional.Text = data.Regional; } } }
/// <summary> /// Load data /// </summary> private void LoadData() { DbHelper.FillList(drpSuppliesStatus, "SELECT C.SuppliesStatus, C.id FROM dbo.BD_Supplies AS A INNER JOIN BD_SuppliesStatus AS B ON A.id = B.SuppliesId INNER JOIN Mst_SuppliesStatus AS C ON A.SuppliesType = C.SuppliesType WHERE B.id = '" + id + "'", "SuppliesStatus", "id"); BD_SuppliesStatusData data = new BD_SuppliesStatusData(); ITransaction tran = factory.GetLoadObject(data, hidId.Value); Execute(tran); if (!HasError) { //Get Data data = (BD_SuppliesStatusData)tran.Result; txtDescription.Text = data.Description; txtProcessDate.Text = data.ProcessDate; txtComment.Text = data.Comment; drpSuppliesStatus.SelectedValue = DbHelper.GetScalar("SELECT C.id FROM dbo.BD_Supplies AS A INNER JOIN BD_SuppliesStatus AS B ON A.id = B.SuppliesId INNER JOIN Mst_SuppliesStatus AS C ON A.SuppliesType = C.SuppliesType WHERE B.id = '" + id + "' and C.SuppliesStatus = N'"+ data.SuppliesStatus +"'"); txtSolution.Text = data.Solution; txtSolutioner.Text = data.Solutioner; txtRegion.Text = data.Region; txtFloor.Text = data.Floor; txtRoom.Text= data.Room; txtSystem.Text = data.System; BD_SuppliesData dataS = new BD_SuppliesData(); ITransaction tranS = factory.GetLoadObject(dataS, data.SuppliesId); Execute(tranS); if (!HasError) { //Get Data dataS = (BD_SuppliesData)tranS.Result; lblCreatedId.Text = dataS.CreatedId; lblName.Text = dataS.Name; } } }