Esempio n. 1
0
    public void GetAllContract()
    {
        int FlagTotalTime;

        colContract = objContract.Get_All_Escalate_Notification();
        foreach (Contract_mst obj in colContract)
        {
            FlagTotalTime = objContract.Get_Contract_Notification_Time(obj.Contractid);
            if (FlagTotalTime <= 0)
            {
                objContractNotification = objContractNotification.Get_By_id(obj.Contractid);
                objContractNotification.Sendnotification = true;
                objContractNotification.Contractid       = obj.Contractid;

                string   varemail    = objContractNotification.Sentto;
                string[] arrEmail    = varemail.Split(',');
                int      lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {
                        objEmail.To         = emailId;
                        objEmail.From       = Resources.MessageResource.strEmailFromLevel1Escalate.ToString();
                        objEmail.Subject    = "Contract is About to Expire  -" + obj.Contractname;
                        objEmail.Body       = "Dear Sir, The Contract " + obj.Contractname + " is going to expire on  " + obj.Activeto + " Please send mail to Renew Contract.  Thanks & Regards Admin";
                        objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                        objEmail.SentMail();
                    }
                }
                objContractNotification.Update();
            }
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {///Add Exception handilng try catch change by vishal 21-05-2012
        try
        {
            string vardateFrom;
            string vardateTo;
            string varemail   = "";
            int    contractid = Convert.ToInt32(Request.QueryString[0]);
            objContract.Contractname = txtContractName.Text;
            objContract.Contractid   = contractid;
            string[] tempdate = txtActiveFrom.Text.ToString().Split(("/").ToCharArray());
            vardateFrom = tempdate[2] + "-" + tempdate[1] + "-" + tempdate[0];

            objContract.Activefrom = vardateFrom;

            string[] tempdate1 = txtActiveTo.Text.ToString().Split(("/").ToCharArray());
            vardateTo               = tempdate1[2] + "-" + tempdate1[1] + "-" + tempdate1[0];
            objContract.Activeto    = vardateTo;
            objContract.Description = txtdesc.Text;
            objContract.Vendorid    = Convert.ToInt32(drpVendor.SelectedValue);
            objContract.Update();
            objContractToAsset.Delete(contractid);
            for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
            {
                objContractToAsset.Assetid    = Convert.ToInt32(ListAsset.Items[i].Value);
                objContractToAsset.Contractid = contractid;
                objContractToAsset.Insert();
            }


            if (chkLevel1.Checked == true)
            {
                for (int i = listLevel1.Items.Count - 1; i >= 0; i--)
                {
                    if (listLevel1.Items[i].Selected == true)
                    {
                        varemail = varemail + listLevel1.Items[i].Text + ",";
                    }
                }

                objContractNotfy.Contractid       = contractid;
                objContractNotfy.Sendnotification = false;
                objContractNotfy.Sentto           = varemail;
                objContractNotfy.Beforedays       = Convert.ToInt32(txtBeforeDays.Text);
                objContractNotfy.Update();
                Response.Redirect("../Contract/DisplayAllContract.aspx");
            }
        }
        catch (Exception ex)
        {
            string myScript;
            myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>";
            Page.RegisterClientScriptBlock("MyScript", myScript);
            return;
        }
    }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        string vardateFrom;
        string vardateTo;
        string varemail   = "";
        int    contractid = Convert.ToInt16(Request.QueryString[0]);

        objContract.Contractname = txtContractName.Text;
        objContract.Contractid   = contractid;
        string[] tempdate = txtActiveFrom.Text.ToString().Split(("/").ToCharArray());
        vardateFrom = tempdate[2] + "-" + tempdate[1] + "-" + tempdate[0];

        objContract.Activefrom = vardateFrom;

        string[] tempdate1 = txtActiveTo.Text.ToString().Split(("/").ToCharArray());
        vardateTo               = tempdate1[2] + "-" + tempdate1[1] + "-" + tempdate1[0];
        objContract.Activeto    = vardateTo;
        objContract.Description = txtdesc.Text;
        objContract.Vendorid    = Convert.ToInt16(drpVendor.SelectedValue);
        objContract.Update();
        objContractToAsset.Delete(contractid);
        for (int i = ListAsset.Items.Count - 1; i >= 0; i--)
        {
            objContractToAsset.Assetid    = Convert.ToInt16(ListAsset.Items[i].Value);
            objContractToAsset.Contractid = contractid;
            objContractToAsset.Insert();
        }


        if (chkLevel1.Checked == true)
        {
            for (int i = listLevel1.Items.Count - 1; i >= 0; i--)
            {
                if (listLevel1.Items[i].Selected == true)
                {
                    varemail = varemail + listLevel1.Items[i].Text + ",";
                }
            }

            objContractNotfy.Contractid       = contractid;
            objContractNotfy.Sendnotification = false;
            objContractNotfy.Sentto           = varemail;
            objContractNotfy.Beforedays       = Convert.ToInt16(txtBeforeDays.Text);
            objContractNotfy.Update();
            Response.Redirect("../Contract/DisplayAllContract.aspx");
        }
    }
    public void GetAllContract()
    {
        int FlagTotalTime;
        colContract = objContract.Get_All_Escalate_Notification();
        foreach (Contract_mst obj in colContract)
        {
            FlagTotalTime = objContract.Get_Contract_Notification_Time(obj.Contractid);
            if (FlagTotalTime <= 0 )
            {
                objContractNotification = objContractNotification.Get_By_id(obj.Contractid);
                objContractNotification.Sendnotification = true ;
                objContractNotification.Contractid = obj.Contractid;

                string varemail = objContractNotification.Sentto;
                string[] arrEmail = varemail.Split(',');
                int lengthCount = Convert.ToInt32(arrEmail.Length.ToString());
                for (int i = 0; i < lengthCount - 1; i++)
                {
                    string emailId = arrEmail[i].ToString();
                    if (emailId != "," && emailId != "")
                    {

                                objEmail.To = emailId;
                                objEmail.From = Resources.MessageResource.strEmailFromLevel1Escalate.ToString();
                                objEmail.Subject = "Contract is About to Expire  -" + obj.Contractname;
                                objEmail.Body = "Dear Sir, The Contract " + obj.Contractname + " is going to expire on  " + obj.Activeto  + " Please send mail to Renew Contract.  Thanks & Regards Admin";
                                objEmail.SmtpServer = Resources.MessageResource.strMailServer.ToString();
                                objEmail.SentMail();

                      }

                    }
                 objContractNotification.Update();

                }

            }
    }