Exemplo n.º 1
0
    public void InsertEmailTaskAlert(ETaskAlert ETA, string IsUpdate, string IsDelete, string strSlNo)
    {
        long intSLNo = Convert.ToInt64(Common.getMaxId("EMAILTASKALERT", "SLNO"));

        SqlCommand cmd = new SqlCommand("proc_Insert_EmailTaskAlert");

        cmd.CommandType = CommandType.StoredProcedure;

        SqlParameter p_TRANSID = cmd.Parameters.Add("TRANSID", SqlDbType.BigInt);

        p_TRANSID.Direction = ParameterDirection.Input;
        p_TRANSID.Value     = ETA.TRANSID;

        SqlParameter p_SLNO = cmd.Parameters.Add("SLNO", SqlDbType.BigInt);

        p_SLNO.Direction = ParameterDirection.Input;
        if (IsUpdate == "Y")
        {
            p_SLNO.Value = strSlNo;
        }
        else
        {
            p_SLNO.Value = intSLNo;
        }

        SqlParameter p_FROMEMPID = cmd.Parameters.Add("FROMEMPID", SqlDbType.Char);

        p_FROMEMPID.Direction = ParameterDirection.Input;
        p_FROMEMPID.Value     = ETA.FROMEMPID;

        SqlParameter p_TOEMPID = cmd.Parameters.Add("TOEMPID", SqlDbType.VarChar);

        p_TOEMPID.Direction = ParameterDirection.Input;
        p_TOEMPID.Value     = ETA.TOEMPID;

        SqlParameter p_FROMADDR = cmd.Parameters.Add("FROMADDR", SqlDbType.VarChar);

        p_FROMADDR.Direction = ParameterDirection.Input;
        p_FROMADDR.Value     = ETA.FROMADDR;

        SqlParameter p_TOADDR = cmd.Parameters.Add("TOADDR", SqlDbType.VarChar);

        p_TOADDR.Direction = ParameterDirection.Input;
        p_TOADDR.Value     = ETA.TOADDR;

        SqlParameter p_CCADDR = cmd.Parameters.Add("CCADDR", SqlDbType.VarChar);

        p_CCADDR.Direction = ParameterDirection.Input;
        p_CCADDR.Value     = ETA.CCADDR;

        SqlParameter p_BCCADDR = cmd.Parameters.Add("BCCADDR", SqlDbType.VarChar);

        p_BCCADDR.Direction = ParameterDirection.Input;
        p_BCCADDR.Value     = ETA.BCCADDR;

        SqlParameter p_SUBJECT = cmd.Parameters.Add("SUBJECT", SqlDbType.VarChar);

        p_SUBJECT.Direction = ParameterDirection.Input;
        p_SUBJECT.Value     = ETA.SUBJECT;

        SqlParameter p_ATTACHMENT = cmd.Parameters.Add("ATTACHMENT", SqlDbType.VarChar);

        p_ATTACHMENT.Direction = ParameterDirection.Input;
        p_ATTACHMENT.Value     = ETA.ATTACHMENT;

        SqlParameter p_BODY = cmd.Parameters.Add("BODY", SqlDbType.VarChar);

        p_BODY.Direction = ParameterDirection.Input;
        p_BODY.Value     = ETA.BODY;

        SqlParameter p_SCHDATETIME = cmd.Parameters.Add("SCHDATETIME", DBNull.Value);

        p_SCHDATETIME.Direction  = ParameterDirection.Input;
        p_SCHDATETIME.IsNullable = true;
        if (ETA.SCHDATETIME != "")
        {
            p_SCHDATETIME.Value = ETA.SCHDATETIME;
        }

        SqlParameter p_STATUS = cmd.Parameters.Add("STATUS", SqlDbType.Char);

        p_STATUS.Direction = ParameterDirection.Input;
        p_STATUS.Value     = ETA.STATUS;

        SqlParameter p_InsertedBy = cmd.Parameters.Add("InsertedBy", SqlDbType.VarChar);

        p_InsertedBy.Direction = ParameterDirection.Input;
        p_InsertedBy.Value     = ETA.InsertedBy;

        SqlParameter p_InsertedDate = cmd.Parameters.Add("InsertedDate", SqlDbType.DateTime);

        p_InsertedDate.Direction = ParameterDirection.Input;
        p_InsertedDate.Value     = ETA.InsertedDate;

        SqlParameter p_IsUpdate = cmd.Parameters.Add("IsUpdate", SqlDbType.Char);

        p_IsUpdate.Direction = ParameterDirection.Input;
        p_IsUpdate.Value     = IsUpdate;

        SqlParameter p_IsDelete = cmd.Parameters.Add("IsDelete", SqlDbType.Char);

        p_IsDelete.Direction = ParameterDirection.Input;
        p_IsDelete.Value     = IsDelete;

        try
        {
            objDC.ExecuteQuery(cmd);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
        finally
        {
            cmd = null;
        }
    }
Exemplo n.º 2
0
    private void SaveData(string IsDelete)
    {
        string strTransID = "";

        if (hfIsUpdate.Value == "N")
        {
            if (hfID.Value != "")
            {
                hfIsUpdate.Value = "Y";
            }
            else
            {
                hfIsUpdate.Value = "N";
            }
        }
        //    hfIsUpdate.Value = objTaskAlt.GetTaskAlert(Session["TRANSID"].ToString());

        try
        {
            string   strAlertDateTime = Common.ReturnDate(txtAltertDate.Text.Trim()) + " " + ddlAlertHour.SelectedValue.ToString() + ":" + ddlAlertMin.SelectedValue.ToString();
            DateTime dateTimeAlert    = Convert.ToDateTime(strAlertDateTime);
            if (chkGroupAttach.Checked == true)
            {
                string   FolderPath    = ConfigurationManager.AppSettings["AttachFilePath"];
                string[] strToEmpArr   = txtTo.ToolTip.Split(',');
                string[] strToEmailArr = txtTo.Text.Split(',');
                string   strAttach     = "";
                string   strSubStr     = "";
                bool     IsAttachFound = false;
                if (strToEmpArr.Length > 0)
                {
                    ETaskAlert[] objETaskAlert = new ETaskAlert[strToEmpArr.Length];
                    for (int i = 0; i < strToEmpArr.Length; i++)
                    {
                        IsAttachFound = false;
                        string[] fileEntries = Directory.GetFiles(ConfigurationManager.AppSettings["AttachTempFilePath"]);
                        foreach (string strFilePath in fileEntries)
                        {
                            string[] strFiles = strFilePath.Split('\\');
                            if (strFiles.Length > 0)
                            {
                                strSubStr = strFiles[strFiles.Length - 1].Substring(0, 8);
                            }
                            if (strToEmpArr[i].ToUpper().Trim() == strSubStr.ToUpper().Trim())
                            {
                                strAttach = strFiles[strFiles.Length - 1];
                                // Client File Path
                                FileInfo orgFile = new FileInfo(ConfigurationManager.AppSettings["AttachTempFilePath"] + "/" + strFiles[strFiles.Length - 1]);


                                string FilePath = Server.MapPath(FolderPath + "/" + strFiles[strFiles.Length - 1]);
                                // Server File Path
                                FileInfo File = new FileInfo(FilePath);
                                if (File.Exists == true)
                                {
                                    File.Delete();
                                }
                                // Upload to Server
                                orgFile.CopyTo(FilePath);

                                strAlertDateTime = Common.SetDateTime(dateTimeAlert.ToString());

                                objETaskAlert[i] = new ETaskAlert(Session["TRANSID"].ToString(), Session["EMPID"].ToString().Trim(), Session["EMAILID"].ToString().Trim(), strToEmpArr[i], strToEmailArr[i], txtCC.Text.Trim(),
                                                                  txtBCC.Text.Trim(), txtSubject.Text.Trim(), strAttach, FreetxtTask.Text.Trim(), strAlertDateTime, "0", Session["USERID"].ToString(),
                                                                  Common.SetDateTime(DateTime.Now.ToString()));

                                dateTimeAlert.AddSeconds(5);
                                IsAttachFound = true;
                            }
                        }
                        if (IsAttachFound == false)
                        {
                            strAlertDateTime = Common.SetDateTime(dateTimeAlert.ToString());

                            objETaskAlert[i] = new ETaskAlert(Session["TRANSID"].ToString(), Session["EMPID"].ToString().Trim(), Session["EMAILID"].ToString().Trim(), strToEmpArr[i], strToEmailArr[i], txtCC.Text.Trim(),
                                                              txtBCC.Text.Trim(), txtSubject.Text.Trim(), "", FreetxtTask.Text.Trim(), strAlertDateTime, "0", Session["USERID"].ToString(),
                                                              Common.SetDateTime(DateTime.Now.ToString()));

                            dateTimeAlert.AddSeconds(5);
                        }
                    }
                    if (objETaskAlert.Length > 0)
                    {
                        objTaskAlt.InsertGroupEmailTaskAlert(objETaskAlert, hfIsUpdate.Value, IsDelete);
                    }
                }

                //ETaskAlert[] objETaskAlert = new ETaskAlert(Session["TRANSID"].ToString(), Session["EMPID"].ToString().Trim(), Session["EMAILID"].ToString().Trim(), txtTo.Text.Trim(), txtCC.Text.Trim(),
                //    txtBCC.Text.Trim(), txtSubject.Text.Trim(), hfAttach.Value.ToString().Trim(), FreetxtTask.Text.Trim(), strAlertDateTime, "0", Session["USERID"].ToString(),
                //    Common.SetDateTime(DateTime.Now.ToString()));
            }
            else
            {
                ETaskAlert objETaskAlert = new ETaskAlert(Session["TRANSID"].ToString(), Session["EMPID"].ToString().Trim(), Session["EMAILID"].ToString().Trim(), txtTo.ToolTip.ToString(), txtTo.Text.Trim(), txtCC.Text.Trim(),
                                                          txtBCC.Text.Trim(), txtSubject.Text.Trim(), hfAttach.Value.ToString().Trim(), FreetxtTask.Text.Trim(), strAlertDateTime, "0", Session["USERID"].ToString(),
                                                          Common.SetDateTime(DateTime.Now.ToString()));

                objTaskAlt.InsertEmailTaskAlert(objETaskAlert, hfIsUpdate.Value, IsDelete, hfID.Value);
            }
            if ((hfIsUpdate.Value == "N") && (IsDelete == "N"))
            {
                lblMsg.Text = "Record Saved Successfully";
            }
            else if ((hfIsUpdate.Value == "Y") && (IsDelete == "N"))
            {
                lblMsg.Text = "Record Updated Successfully";
            }
            else if (IsDelete == "Y")
            {
                lblMsg.Text = "Record Deleted Successfully";
            }
            this.OpenRecord();
            hfID.Value = "";
            //Common.EmptyTextBoxValues(this);
            this.EntryMode(false);
        }
        catch (Exception ex)
        {
            lblMsg.Text = "";
            throw (ex);
        }
    }