Пример #1
0
        /// <summary>
        /// Load data
        /// </summary>
        private void LoadData()
        {
            BD_DocumentData data = new BD_DocumentData();
            ITransaction tran = factory.GetLoadObject(data, hidId.Value);
            Execute(tran);
            if (!HasError)
            {
                data = (BD_DocumentData)tran.Result;

                txtName.Text = data.Name;
                txtComment.Text = data.Comment;
                txtDocDate.Text = Func.FormatDMY(data.DocDate);
                txtAppeal.Text = data.Appeal;
                //if (data.InOutDoc == "0")
                //{ rdoInDoc.Checked = true; }
                //else
                //{
                //    rdoOutDoc.Checked = true;
                //}

                //if (data.DocFrom == "0")
                //{
                //    rdoCDT.Checked = true;
                //}
                //else
                //{
                //    rdoCustomer.Checked = true;
                //}

                //DbHelper.FillList      (drpDocSubject, "Select * from BD_DocSubject where BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' and DocType = '" + data.DocType + "' and (DelFlag is null or DelFlag = '0')", "DocSubject", "id");
                DbHelper.FillListSearch(drpDocSubject, "Select * from BD_DocSubject where BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' and DocType = '" + data.DocType + "' and (DelFlag is null or DelFlag = '0')", "DocSubject", "id");
                DbHelper.FillListSearch(drpParentId, "Select * from BD_DocSubject where BuildingId = '" + Func.ParseString(Session["__BUILDINGID__"]) + "' and DocType = '" + data.DocType + "' and (DelFlag is null or DelFlag = '0') and ParentId is null", "DocSubject", "id");
                drpDocSubject.SelectedValue = data.DocSubject;
                drpParentId.SelectedValue = DbHelper.GetScalar("Select ParentId from BD_DocSubject where id = '" + data.DocSubject + "'");

                tran = factory.GetUpdateObject(data);
                Execute(tran);

                if (!HasError)
                {
                    OperationLogger.WriteInfo(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addSuccess, Page.User.Identity.Name);
                }
                else
                {
                    OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                    mvMessage.AddError(addUnSuccess);
                }
            }
        }
Пример #2
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            mvMessage.CheckRequired(txtName, "Tên hồ sơ: là Danh mục bắt bắt buộc nhập");
            if (!mvMessage.IsValid) return;

            try
            {
                BD_DocumentData data = new BD_DocumentData();
                ITransaction tran = factory.GetLoadObject(data, hidId.Value);
                Execute(tran);
                if (!HasError)
                {
                    data = (BD_DocumentData)tran.Result;
                    data.Name = txtName.Text.Trim();
                    data.Comment = txtComment.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.Appeal = txtAppeal.Text;
                    //data.InOutDoc = rdoInDoc.Checked == true ? "0" : "1";
                    //data.DocFrom = rdoCDT.Checked == true ? "0" : "1";
                    data.DocSubject = drpDocSubject.SelectedValue;
                    data.DocDate = Func.FormatYYYYmmdd(txtDocDate.Text.Trim());

                    if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
                    {
                        string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
                        string filename = Func.ParseString(Session["__BUILDINGID__"])
                            + "_" + data.DocType + "_" + DateTime.Now.ToString("yyyyMMddHHmmss")
                            + fn;
                        string SaveLocation = Server.MapPath("Data") + "\\" + filename;
                        File1.PostedFile.SaveAs(SaveLocation);
                        data.FileNamePath = filename;
                    }
                    tran = factory.GetUpdateObject(data);
                    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);
                    }
                    else
                    {
                        OperationLogger.WriteError(Constants.LogOperationAlbumId, Constants.LogActionInsertId, addUnSuccess, Page.User.Identity.Name);
                        mvMessage.AddError(addUnSuccess);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
            //else
            //{
            //    Response.Write("Please select a file to upload.");
            //}
        }
Пример #3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            mvMessage.CheckRequired(txtName, "Tên hồ sơ: là Danh mục bắt bắt buộc nhập");
            if (!mvMessage.IsValid) return;

            if ((File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
            {
                string fn = System.IO.Path.GetFileName(File1.PostedFile.FileName);
                string filename = Func.ParseString(Session["__BUILDINGID__"])
                    + "_" + hidDocType.Value + "_" + DateTime.Now.ToString("yyyyMMddHHmmss")
                    + fn;
                string SaveLocation = Server.MapPath("Data") + "\\" + filename;
                try
                {

                    File1.PostedFile.SaveAs(SaveLocation);

                    BD_DocumentData data = new BD_DocumentData();
                    ITransaction tran = factory.GetInsertObject(data);

                    data.Name = txtName.Text.Trim();
                    data.BuildingId = Func.ParseString(Session["__BUILDINGID__"]);
                    data.Comment = txtComment.Text.Trim();
                    data.FileNamePath = filename;
                    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";
                    data.DocType = hidDocType.Value;
                    data.Appeal = txtAppeal.Text;
                    data.DocDate = Func.FormatYYYYmmdd(txtDocDate.Text.Trim());
                    //data.InOutDoc = rdoInDoc.Checked == true ? "0" : "1";
                    //data.DocFrom = rdoCDT.Checked == true ? "0" : "1";
                    data.DocSubject = drpDocSubject.SelectedValue;

                    switch (hidDocType.Value)
                    {
                        case "1":
                            break;
                        case "2":
                            data.Dept = "2";
                            break;
                        case "3":
                            data.Dept = "3";
                            break;
                        case "4":
                            data.Dept = "4";
                            break;
                        //case "5":
                        //    data.ContractId = hidId.Value;
                        //    break;
                        //case "6":
                        //    data.CustomerId =  hidId.Value;
                        //    break;
                        //case "7":
                        //    data.StaffId =  hidId.Value;
                        //    break;
                        //case "8":
                        //    data.SuppliesId =  hidId.Value;
                        //    break;
                        //case "9":
                        //    data.EquipmentId = hidId.Value;
                        //    break;
                        case "5":
                        case "6":
                        case "7":
                        case "8":
                        case "9":
                            data.DocTypeId = hidId.Value;
                            break;
                        default:
                            break;
                    }

                    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";
                        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. 
                }
            }
            else
            {
                Response.Write("Please select a file to upload.");
            }


        }
Пример #4
0
        /// </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;
                pager1.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("View"))
            {
                string path = (string)e.CommandArgument;
                string[] str = path.Split('$');
                BD_DocumentDownloadData data = new BD_DocumentDownloadData();
                ITransaction tran = factory.GetInsertObject(data);
                data.DocId = str[0];
                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);
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "", "PopUp('./Data/" + str[1] + "'," + PopupWidth + "," + PopupHeight + ",'EditReport', true);", true);
            }
            //else if (command.Equals("Update"))
            //{
            //    PopupWidth = 600;
            //    PopupHeight = 450;

            //    string id = (string)e.CommandArgument;
            //    ScriptManager.RegisterStartupScript(Page, this.GetType(), "", "PopUp('./" + editPageName + ".aspx?DocType=" + hidDocType.Value + "&Id=" + id + "'," + PopupWidth + "," + PopupHeight + ",'EditReport', true);", true);
            //}
            else if (command.Equals("Delete"))
            {
                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.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();
                }
            }
        }
Пример #5
0
        /// </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");

                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.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("View"))
            {
                string path = (string)e.CommandArgument;
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "", "PopUp('./Data/" + path + "'," + PopupWidth + "," + PopupHeight + ",'EditReport', true);", true);
            }
            else if (command.Equals("Delete"))
            {
                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.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();
                }
            }
        }