Exemplo n.º 1
0
    protected void btnUpdateReassign_Click(object sender, EventArgs e)
    {
        clsMRCFAssign objAssign = new clsMRCFAssign();

        objAssign.HandlerCode = objAssign.GetHandlerCode(Request.QueryString["mrcfcode"].ToString());
        objAssign.AssignBy    = Request.Cookies["Speedo"]["UserName"].ToString(); //objAssign.GetProcurementManager("PROCMNGR");
        objAssign.CreateBy    = Request.Cookies["Speedo"]["UserName"].ToString();
        objAssign.IsActive    = "1";                                              //1 = Active , 0 = Inactive
        objAssign.AssignTo    = ddlReassign.SelectedValue.ToString();
        objAssign.Remarks     = txtReassignRemarks.Text;
        objAssign.StatusCode  = objAssign.LoadCurrentStatus(Request.QueryString["mrcfcode"]);
        objAssign.AssignEmployeeDetails("Reassign");
        Response.Redirect("MRCFMenu.aspx");
    }
Exemplo n.º 2
0
    protected void btnApprove_Click(object sender, EventArgs e)
    {
        if (!clsOracleMrcf.IsOracleUp())
        {
            Response.Redirect("OracleDatabaseProblem.aspx");
        }

        clsMRCFAssign objAssign = new clsMRCFAssign();

        objAssign.MRCFCode   = Request.QueryString["mrcfcode"].ToString();
        objAssign.AssignBy   = objAssign.GetProcurementManager("PROCMNGR");
        objAssign.CreateBy   = objAssign.GetProcurementManager("PROCMNGR");
        objAssign.IsActive   = "1"; //1 = Active , 0 = Inactive
        objAssign.AssignTo   = ddlAssign.SelectedValue.ToString();
        objAssign.Remarks    = txtAssignRemarks.Text;
        objAssign.StatusCode = objAssign.GetInitialStatusCode();
        objAssign.AssignEmployee();
        objAssign.AssignEmployeeDetails("None");


        using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Speedo"].ToString()))
        {
            SqlCommand cmd = cn.CreateCommand();
            cn.Open();


            //Retrieve information of MRCF
            DataTable tblMRCF = clsOracleMrcf.GetMRCFDetails(Request.QueryString["mrcfcode"]);

            using (clsOracleMrcf ReqMrcf = new clsOracleMrcf())
            {
                //Update MRCF status
                cmd.CommandText = "UPDATE CIS.Mrcf SET status='A',procstat='A',sprvstat=@sprvstat,headstat=@headstat,procdate='" + DateTime.Now + "',procrem=@procrem WHERE mrcfcode='" + Request.QueryString["mrcfcode"] + "'";
                cmd.Parameters.Add("@procrem", SqlDbType.VarChar, 200);
                cmd.Parameters.Add("@sprvstat", SqlDbType.Char, 1);
                cmd.Parameters.Add("@headstat", SqlDbType.Char, 1);
                cmd.Parameters["@procrem"].Value  = txtProcMngrRem.Text;
                cmd.Parameters["@sprvstat"].Value = (hdnGrpHeadStat.Value == "F" ? "N" : hdnGrpHeadStat.Value);
                cmd.Parameters["@headstat"].Value = (hdnDiviHeadStat.Value == "F" ? "N" : hdnDiviHeadStat.Value);
                cmd.ExecuteNonQuery();
                cmd.Parameters.Clear();

                //Update MRCF Details
                cmd.CommandText = "UPDATE CIS.MrcfDetails SET itemspec=@itemspec WHERE mitmcode=@mitmcode";
                cmd.Parameters.Add("@itemspec", SqlDbType.VarChar, 5000);
                cmd.Parameters.Add("@mitmcode", SqlDbType.BigInt);
                foreach (DataGridItem itm in dgItems.Items)
                {
                    HiddenField phdnMitmCode = (HiddenField)itm.FindControl("hdnMitmCode");
                    TextBox     ptxtItemSpec = (TextBox)itm.FindControl("txtItemSpec");
                    cmd.Parameters["@itemspec"].Value = ptxtItemSpec.Text;
                    cmd.Parameters["@mitmcode"].Value = phdnMitmCode.Value;
                    cmd.ExecuteNonQuery();
                }
                cmd.Parameters.Clear();

                clsMRCF.SendNotification(clsMRCF.MRCFMailType.ApproveToRequestor, txtRequestorName.Text, txtProcMngrName.Text, hdnRequestorMail.Value, txtMrcfCode.Text);
                clsMRCF.SendNotification(clsMRCF.MRCFMailType.ApproveToApproverPM, txtRequestorName.Text, txtProcMngrName.Text, clsUsers.GetEmail(Request.Cookies["Speedo"]["UserName"].ToString()), txtMrcfCode.Text);


                //Validate if the Request is not canvass only. If Not it will enter the ORACLE for Interfacing.
                if (clsMRCF.GetRequestType(Request.QueryString["mrcfcode"]) != "C")
                {
                    //Generate batch entry number
                    int intBatchCode = 0;
                    cmd.CommandText = "SELECT pvalue FROM Speedo.Keys WHERE pkey='btchcode'";
                    intBatchCode    = cmd.ExecuteScalar().ToString().ToInt() + 1;
                    cmd.Parameters.Clear();
                    ReqMrcf.BatchId = intBatchCode;

                    if (ReqMrcf.Insert(tblMRCF) == 1)
                    {
                        //Delete MRCF and Batch if existing
                        cmd.CommandText = "DELETE FROM CIS.MrcfBatch WHERE mrcfcode= @mrcfcode";
                        cmd.Parameters.Add(new SqlParameter("@mrcfcode", Request.QueryString["mrcfcode"].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@btchcode", intBatchCode));
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();

                        //Insert MRCFCode and Batch code of Approved MRCF that is uploaded in interface table
                        cmd.CommandText = "INSERT INTO CIS.MrcfBatch VALUES (@mrcfcode,@btchcode)";
                        cmd.Parameters.Add(new SqlParameter("@mrcfcode", Request.QueryString["mrcfcode"].ToString()));
                        cmd.Parameters.Add(new SqlParameter("@btchcode", intBatchCode));
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();

                        //Increment Batchcode in SPeedo.Keys
                        cmd.CommandText = "UPDATE Speedo.Keys SET pvalue=(pvalue+1) WHERE pkey='btchcode'";
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();
                    }

                    Response.Redirect("MRCFMenu.aspx");
                }
                else
                {
                    Response.Redirect("MRCFMenu.aspx");
                }
            }
        }
    }