Example #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        CVoiceUI objUI = new CVoiceUI();
        MastersController objController = new MastersController();
        string lblMsg = "";
        int GroupID = 0;
        int CVoiceCode = Convert.ToInt32(txtCVoiceCode.Text.Trim());
        if (rdoAdd.Checked)
        {
            GroupID = SaveCVoiceGroup();
        }
        if (rdoAssign.Checked)
        {
            if (drpCVoiceGroup.SelectedIndex != 0)
            {
                GroupID = Convert.ToInt32(drpCVoiceGroup.SelectedValue);
            }
        }
        if (GroupID > 0)
        {
            string strDescription = txtDesc.Text.Trim();
            int IsActive = 0;
            if (chkActive.Checked)
            {
                IsActive = 1;
            }
            else
            {
                IsActive = 0;
            }
            int InReport = 0;
            if (chkReport.Checked)
            {
                InReport = 1;
            }
            else
            {
                InReport = 0;
            }

           // string strDate = getDate(strCalDate);
            objUI.CVoiceCode = CVoiceCode;
            objUI.GroupID = GroupID;
            objUI.Description = strDescription;
            objUI.IsActive = IsActive;
            objUI.InReport = InReport;
            objUI.IsGroup = 1;

            //string DateTimeAppointment = Convert.ToString(CalstartDate.SelectedDate);
            string Date = objDate.ConvertDateFormat(CalstartDate.Value);
            if (Date == "")
            {
                objUI.EffectDate = Convert.ToDateTime("1/1/1900");
            }
            else
            {
                objUI.EffectDate = Convert.ToDateTime(Date);
            }
            objUI.StatusID = Convert.ToInt32(hdnStatusID.Value);
            //string strQuery = "Insert into Culprit (Code,Description,IsActive,InReport,EffectDate) values (" + CulpritCode + ",'" + strDescription + "'," + IsActive + "," + InReport + ",'" + strDate + "')";
            try
            {
                objController.AddCVoice(objUI, null);
                Response.Redirect(strProjectName+"/View/Forms/Master/CustumerVoiceDefault.aspx");
            }
            catch (Exception ex)
            {
                string strMessage = ex.Message;
                if (strMessage.Contains("Cannot insert duplicate"))
                {
                    lblMsg = "Cannot insert duplicate value, Please check the culprit code";
                    string strjscript = "<script language='javascript'>";
                    strjscript += " setMessageText('ctl00_ContentPlaceHolder1_lblMessage','" + lblMsg + "' );";
                    strjscript += "</script" + ">";
                    Literal1.Text = strjscript;
                    // lblMessage.Text = "Cannot insert duplicate value, Please check the culprit code";
                }
                else
                {
                    lblMsg = "Record could not be added successfully";
                    string strjscript = "<script language='javascript'>";
                    strjscript += " setMessageText('ctl00_ContentPlaceHolder1_lblMessage','" + lblMsg + "' );";
                    strjscript += "</script" + ">";
                    Literal1.Text = strjscript;
                    //lblMessage.Text = "Record could not be added successfully";
                }
            }
        }
    }