Esempio n. 1
0
    protected void SaveData(bool pFinalize)
    {
        string username      = Request.Cookies["Speedo"]["UserName"];
        string fileName      = "";
        bool   blnIsApprover = false;

        if (Validate())
        {
            using (clsGroupUpdate objEdit = new clsGroupUpdate())
            {
                fileName = System.Guid.NewGuid().ToString() + Path.GetExtension(fuAttachment.FileName);
                int intGroupUpdateCode = Request.QueryString["GroupUpdateCode"].ToString().ToInt();
                objEdit.GroupUpdateCode = intGroupUpdateCode;
                objEdit.Title           = txtTitle.Text;
                objEdit.Description     = txtDescription.Text;
                objEdit.Content         = ckeContents.Text;
                objEdit.DepartmentCode  = clsEmployee.GetDepartmentCode(username);
                objEdit.DivisionCode    = clsEmployee.GetDivisionCode(username);
                objEdit.CreateBy        = username;
                objEdit.ModifyBy        = username;
                objEdit.Status          = hdnGroupHead.Value == username ? "1" : "0";
                objEdit.Enabled         = "1";
                objEdit.Contributor     = txtContributor.Text;
                objEdit.PhotoSource     = txtPhotoSource.Text;

                if (fuAttachment.HasFile)
                {
                    objEdit.ImageFilename = fileName;
                }
                else
                {
                    objEdit.ImageFilename = "";
                }

                if (pFinalize == true)
                {
                    if (objEdit.Status == "1")
                    {
                        blnIsApprover = true;
                    }
                }
                else
                {
                    //Save As draft
                    objEdit.Status = "5";
                }


                if (objEdit.Update(blnIsApprover) > 0)
                {
                    if (fuAttachment.HasFile)
                    {
                        fuAttachment.SaveAs(Server.MapPath(@"~\UploadedFiles\GroupUpdates\" + fileName));
                    }

                    if (hndIsPreview.Value == string.Empty)
                    {
                        Response.Redirect("GroupUpdateMain.aspx");
                    }
                }
            }
        }
    }
Esempio n. 2
0
    protected void SaveData(bool pFinalize)
    {
        string    username      = Request.Cookies["Speedo"]["UserName"];
        string    fileName      = "";
        bool      blnIsApprover = false;
        DataTable tblApprover   = new DataTable();

        tblApprover.Columns.Add("ApprovalLevel");
        tblApprover.Columns.Add("Username");

        //Add Grouphead in datatable
        DataRow drnew = tblApprover.NewRow();

        drnew["ApprovalLevel"] = "1";
        drnew["Username"]      = hdnGroupHead.Value;
        tblApprover.Rows.Add(drnew);

        //Add DivisionHead in datatable
        //drnew = tblApprover.NewRow();
        //drnew["ApprovalLevel"] = "2";
        //drnew["Username"] = hdnDivisionHead.Value;
        //tblApprover.Rows.Add(drnew);

        if (Validate())
        {
            using (clsGroupUpdate objAdd = new clsGroupUpdate())
            {
                fileName              = System.Guid.NewGuid().ToString() + Path.GetExtension(fuAttachment.FileName);
                objAdd.Title          = txtTitle.Text;
                objAdd.Description    = txtDescription.Text;
                objAdd.Content        = ckeContents.Text;
                objAdd.DepartmentCode = clsEmployee.GetDepartmentCode(username);
                objAdd.DivisionCode   = clsEmployee.GetDivisionCode(username);
                objAdd.Contributor    = txtContributor.Text;
                objAdd.PhotoSource    = txtPhotoSource.Text;
                objAdd.CreateBy       = username;
                objAdd.ModifyBy       = username;
                objAdd.Status         = hdnGroupHead.Value == username ? "1" : "0";
                objAdd.Enabled        = "1";
                objAdd.ImageFilename  = fileName;

                if (pFinalize == true)
                {
                    if (objAdd.Status == "1")
                    {
                        blnIsApprover = true;
                    }
                }
                else
                {
                    //Save As draft
                    objAdd.Status = "5";
                }

                if (hndGroupUpdateCode.Value == string.Empty)
                {
                    int intGroupUpdateCode = objAdd.Insert(tblApprover, blnIsApprover);
                    if (intGroupUpdateCode > 0)
                    {
                        fuAttachment.SaveAs(Server.MapPath(@"~\UploadedFiles\GroupUpdates\" + fileName));

                        if (pFinalize == true)
                        {
                            Response.Redirect("GroupUpdateMain.aspx");
                        }
                        else
                        {
                            hndGroupUpdateCode.Value = intGroupUpdateCode.ToString();
                        }
                    }
                }
                else
                {
                    if (fuAttachment.HasFile)
                    {
                        objAdd.ImageFilename = fileName;
                    }
                    else
                    {
                        objAdd.ImageFilename = "";
                    }

                    objAdd.GroupUpdateCode = hndGroupUpdateCode.Value.ToString().ToInt();
                    if (objAdd.Update(blnIsApprover) > 0)
                    {
                        if (fuAttachment.HasFile)
                        {
                            fuAttachment.SaveAs(Server.MapPath(@"~\UploadedFiles\GroupUpdates\" + fileName));
                        }
                        if (hndIsPreview.Value == string.Empty)
                        {
                            Response.Redirect("GroupUpdateMain.aspx");
                        }
                    }
                }
            }
        }
    }