protected void GridViewCustomDetail_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                switch (e.CommandName.ToLower())
                {
                case "editcustomdetail":
                {
                    ViewState["insightSupplierCustomDetailId"] = Convert.ToInt32(e.CommandArgument);
                    BindCustomDetail(Convert.ToInt32(e.CommandArgument));
                    break;
                }

                case "removecustomdetail":
                {
                    InsightSupplierCustomDetail.DeleteInsightSupplierCustomDetailByInsightSupplierCustomDetailId(Convert.ToInt32(e.CommandArgument));
                    ViewState["insightSupplierCustomDetailId"] = "0";
                    BindGridViewCustomDetail();
                    break;
                }
                }
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
            }
        }
        private void BindCustomDetail(int customDetailId)
        {
            InsightSupplierCustomDetail insightSupplierCustomDetail = InsightSupplierCustomDetail.GetInsightSupplierCustomDetailByInsightSupplierCustomDetailId(customDetailId);

            this.insightSupplierCustomDetailId = insightSupplierCustomDetail.InsightSupplierCustomDetailId;
            this.insightSupplierId             = insightSupplierCustomDetail.InsightSupplierId;
            DropDownListCustomType.ClearSelection();
            DropDownListCustomType.Items.FindByValue(insightSupplierCustomDetail.CustomTypeId.ToString()).Selected = true;
            DropDownListCustomFrequency.ClearSelection();
            DropDownListCustomFrequency.Items.FindByValue(insightSupplierCustomDetail.CustomFrequencyId.ToString()).Selected = true;
            DropDownListCustomResponsibility.ClearSelection();
            DropDownListCustomResponsibility.Items.FindByValue(insightSupplierCustomDetail.CustomResponsibilityId.ToString()).Selected = true;
            TextBoxDetail.Text     = insightSupplierCustomDetail.Detail;
            TextBoxSourceFile.Text = insightSupplierCustomDetail.SourceFile;
            DropDownListStatus.ClearSelection();
            DropDownListStatus.Items.FindByValue(insightSupplierCustomDetail.StatusId.ToString()).Selected = true;
        }
        private bool SaveInsightSupplierCustomDetail()
        {
            bool hasError    = false;
            bool hasEntry    = false;
            bool returnValue = true;

            LabelError.Text    = "";
            PanelError.Visible = false;

            if (DropDownListCustomType.SelectedValue == "0")
            {
                LabelError.Text += " Type is required.";
                hasError         = true;
            }
            else
            {
                hasEntry = true;
            }

            if (DropDownListCustomFrequency.SelectedValue == "0")
            {
                LabelError.Text += " Frequency is required.";
                hasError         = true;
            }
            else
            {
                hasEntry = true;
            }

            if (DropDownListCustomResponsibility.SelectedValue == "0")
            {
                LabelError.Text += " Responsibility is required.";
                hasError         = true;
            }
            else
            {
                hasEntry = true;
            }

            if (TextBoxDetail.Text.Length == 0)
            {
                LabelError.Text += " Detail is required.";
                hasError         = true;
            }
            else
            {
                hasEntry = true;
            }

            if (TextBoxSourceFile.Text.Length == 0)
            {
                LabelError.Text += " Source File is required.";
                hasError         = true;
            }
            else
            {
                hasEntry = true;
            }

            if (hasEntry == true)
            {
                LabelError.Text += " Please complete all required fields.";
            }

            if (hasEntry == true)
            {
                if (hasError == true)
                {
                    PanelError.Visible = true;
                    return(false);
                }
            }

            InsightSupplierCustomDetail customDetail = new InsightSupplierCustomDetail();

            customDetail.InsightSupplierCustomDetailId = (ViewState["insightSupplierCustomDetailId"] == null) ? 0 : Convert.ToInt32(ViewState["insightSupplierCustomDetailId"]);//this.insightSupplierCustomDetailId;
            customDetail.InsightSupplierId             = this.insightSupplierId;
            customDetail.CustomTypeId           = Convert.ToInt32(DropDownListCustomType.SelectedValue);
            customDetail.CustomFrequencyId      = Convert.ToInt32(DropDownListCustomFrequency.SelectedValue);
            customDetail.CustomResponsibilityId = Convert.ToInt32(DropDownListCustomResponsibility.SelectedValue);
            customDetail.Detail       = TextBoxDetail.Text;
            customDetail.SourceFile   = TextBoxSourceFile.Text;
            customDetail.StatusId     = Convert.ToInt32(DropDownListStatus.SelectedValue);
            customDetail.ModifiedUser = Context.User.Identity.GetUserName();

            try
            {
                customDetail.Save();
                BindCustomDetail(customDetail.InsightSupplierCustomDetailId);
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                LabelError.Text = "";
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />");
                    //LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                returnValue = false;
            }

            return(returnValue);
        }
 private void BindGridViewCustomDetail()
 {
     GridViewCustomDetail.DataSource = InsightSupplierCustomDetail.GetInsightSupplierCustomDetailByInsightSupplierId(this.insightSupplierId);
     GridViewCustomDetail.DataBind();
 }