/// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { string command = e.CommandName; string colName = string.Empty; if (command.StartsWith("Sort")) { if (string.Compare(command, "SortID") == 0) { colName = "ID"; } else if (string.Compare(command, "SortName") == 0) { colName = "Name"; } else if (string.Compare(command, "SortModifiedBy") == 0) { colName = "ModifiedBy"; } else if (string.Compare(command, "SortModified") == 0) { colName = "Modified"; } if (colName == ListSortExpression) { ListSortDirection = (ListSortDirection == SortDirection.Ascending ? SortDirection.Descending : SortDirection.Ascending); } else { ListSortDirection = SortDirection.Descending; } ListSortExpression = colName; pager.CurrentPageIndex = 0; ShowData(); } //else if (command.Equals("Update")) //{ // TextBox txtName = (TextBox)e.Item.FindControl("txtName"); // TextBox txtComment = (TextBox)e.Item.FindControl("txtComment"); // RadioButton irdoInDoc = (RadioButton)e.Item.FindControl("irdoInDoc"); // RadioButton irdoOutDoc = (RadioButton)e.Item.FindControl("irdoOutDoc"); // RadioButton irdoCDT = (RadioButton)e.Item.FindControl("irdoCDT"); // RadioButton irdoCustomer = (RadioButton)e.Item.FindControl("irdoCustomer"); // TextBox itxtAppeal = (TextBox)e.Item.FindControl("itxtAppeal"); // BD_DocumentData data = new BD_DocumentData(); // ITransaction tran = factory.GetLoadObject(data, Func.ParseString(e.CommandArgument)); // Execute(tran); // if (!HasError) // { // //Get Data // data = (BD_DocumentData)tran.Result; // data.Name = txtName.Text.Trim(); // data.Comment = txtComment.Text.Trim(); // data.Appeal = itxtAppeal.Text; // data.InOutDoc = irdoInDoc.Checked.Equals(true) ? "0" : "1"; // data.DocFrom = irdoCDT.Checked.Equals(true) ? "0" : "1"; // data.ModifiedBy = Page.User.Identity.Name; // data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); // 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); // } // else // { // OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); // mvMessage.AddError(updateUnSuccess); // } // ShowData(); // } //} else if (command.Equals("Update")) { TextBox txtDocSubject = (TextBox)e.Item.FindControl("txtDocSubject"); TextBox txtComment = (TextBox)e.Item.FindControl("txtComment"); DropDownList drpParent = (DropDownList)e.Item.FindControl("drpParentId"); BD_DocSubjectData data = new BD_DocSubjectData(); ITransaction tran = factory.GetLoadObject(data, Func.ParseString(e.CommandArgument)); Execute(tran); if (!HasError) { //Get Data data = (BD_DocSubjectData)tran.Result; data.DocSubject = txtDocSubject.Text; data.Comment = txtComment.Text; data.ParentId = drpParent.SelectedValue; data.ModifiedBy = Page.User.Identity.Name; data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); 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); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); mvMessage.AddError(updateUnSuccess); } ShowData(); } } else if (command.Equals("Delete")) { BD_DocSubjectData data = new BD_DocSubjectData(); ITransaction tran = factory.GetLoadObject(data, Func.ParseString(e.CommandArgument)); Execute(tran); if (!HasError) { //Get Data data = (BD_DocSubjectData)tran.Result; data.DelFlag = "1"; data.ModifiedBy = Page.User.Identity.Name; data.Modified = DateTime.Now.ToString("yyyyMMddHHmmss"); 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); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionUpdateId, updateUnSuccess, Page.User.Identity.Name); mvMessage.AddError(updateUnSuccess); } ShowData(); } } }
protected void btnRegister_Click(object sender, EventArgs e) { mvMessage.CheckRequired(txtDocSubject, "Nhóm hồ sơ: là Danh mục bắt bắt buộc nhập"); if (!mvMessage.IsValid) return; try { BD_DocSubjectData data = new BD_DocSubjectData(); ITransaction tran = factory.GetInsertObject(data); data.DocSubject = txtDocSubject.Text.Trim(); data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]); data.Comment = txtComment.Text.Trim(); data.DocType = drpDocType.SelectedValue; 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 = "0"; Execute(tran); data.ParentId = drpParentId.SelectedValue; 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"; hidAction.Value = "Edit"; //hidId.Value = data.id; ShowData(); } else { OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name); mvMessage.AddError(addUnSuccess); } } catch (Exception ex) { Response.Write("Error: " + ex.Message); //Note: Exception.Message returns a detailed message that describes the current exception. //For security reasons, we do not recommend that you return Exception.Message to end users in //production environments. It would be better to put a generic error message. } }