protected void ButtonAddInsightSupplierContactLink_Click(object sender, EventArgs e)
        {
            InsightSupplierContactLink insightSupplierContactLink = new InsightSupplierContactLink();

            insightSupplierContactLink.InsightSupplierContactId = Convert.ToInt32(DropDownListInsightSupplierContact.SelectedValue);
            insightSupplierContactLink.InsightSupplierId        = this.insightSupplierId;
            insightSupplierContactLink.ModifiedUser             = Context.User.Identity.GetUserName();
            insightSupplierContactLink.Save();

            BindInsightSupplierContactList();
            BindInsightSupplierContactGridView();
        }
Exemple #2
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                InsightSupplierContact insightSupplierContact = new InsightSupplierContact();
                insightSupplierContact.InsightSupplierContactId = this.insightSupplierContactId;
                //insightSupplierContact.AccountId = Convert.ToInt32(DropDownListAccount.SelectedValue);
                insightSupplierContact.FirstName      = TextBoxFirstName.Text;
                insightSupplierContact.LastName       = TextBoxLastName.Text;
                insightSupplierContact.Landline       = TextBoxLandline.Text;
                insightSupplierContact.Mobile         = (TextBoxMobile.Text.Length == 0) ? "" : TextBoxMobile.Text;
                insightSupplierContact.Email          = (TextBoxEmail.Text.Length == 0) ? "" : TextBoxEmail.Text;
                insightSupplierContact.Address        = (TextBoxAddress.Text.Length == 0) ? "" : TextBoxAddress.Text;
                insightSupplierContact.RegionId       = Convert.ToInt32(DropDownListRegion.SelectedValue);
                insightSupplierContact.Gift           = Convert.ToInt32(DropDownListGift.SelectedValue);
                insightSupplierContact.AccessMethodId = Convert.ToInt32(DropDownListAccessMethod.SelectedValue);
                insightSupplierContact.Position       = (TextBoxPosition.Text.Length == 0) ? "" : TextBoxPosition.Text;
                insightSupplierContact.ModifiedUser   = Context.User.Identity.GetUserName();

                try
                {
                    insightSupplierContact.Save();
                    int insightSupplierContactId = insightSupplierContact.InsightSupplierContactId;

                    InsightSupplierContactLicense insightSupplierContactLicenseRow = InsightSupplierContactLicense.GetInsightSupplierContactLicenseByInsightSupplierContactIdAccessMethodId(insightSupplierContact.InsightSupplierContactId, Convert.ToInt32(DropDownListAccessMethod.SelectedValue));

                    if (Convert.ToInt32(DropDownListAccessMethod.SelectedValue) == 1) //Online
                    {
                        InsightSupplierContactLicense insightSupplierContactLicense = new InsightSupplierContactLicense();
                        insightSupplierContactLicense.InsightSupplierContactLicenseId = insightSupplierContactLicenseRow.InsightSupplierContactLicenseId;
                        insightSupplierContactLicense.InsightSupplierContactId        = insightSupplierContact.InsightSupplierContactId;
                        insightSupplierContactLicense.AccessMethodId    = Convert.ToInt32(DropDownListAccessMethod.SelectedValue);
                        insightSupplierContactLicense.Username          = TextBoxUsername.Text;
                        insightSupplierContactLicense.Password          = TextBoxPassword.Text;
                        insightSupplierContactLicense.LicenseId         = 0;
                        insightSupplierContactLicense.QlikviewVersionId = 0;
                        insightSupplierContactLicense.ModifiedUser      = Context.User.Identity.GetUserName();
                        insightSupplierContactLicense.Save();

                        BindLicenseGridView(insightSupplierContact.InsightSupplierContactId);
                    }

                    //InsightSupplierContactLicense.UpdateInsightSupplierContactLicenseInSparMapperByInsightSupplierContactLicenseId(insightSupplierContactLicenseRow.InsightSupplierContactLicenseId, (TextBoxInSparMapperUsername.Text.Length > 0) ? TextBoxInSparMapperUsername.Text : "", (TextBoxInSparMapperPassword.Text.Length > 0) ? TextBoxInSparMapperPassword.Text : "", Context.User.Identity.GetUserName());
                    InsightSupplierContactLicense.UpdateInsightSupplierContactLicenseInSparMapperByInsightSupplierContactId(insightSupplierContact.InsightSupplierContactId, (TextBoxInSparMapperUsername.Text.Length > 0) ? TextBoxInSparMapperUsername.Text : "", (TextBoxInSparMapperPassword.Text.Length > 0) ? TextBoxInSparMapperPassword.Text : "", Context.User.Identity.GetUserName());

                    if (this.insightSupplierId != 0)
                    {
                        InsightSupplierContactLink insightSupplierContactLink = new InsightSupplierContactLink();
                        insightSupplierContactLink.InsightSupplierContactId = insightSupplierContact.InsightSupplierContactId;
                        insightSupplierContactLink.InsightSupplierId        = this.insightSupplierId;
                        insightSupplierContactLink.ModifiedUser             = Context.User.Identity.GetUserName();
                        insightSupplierContactLink.Save();

                        BindInsightSupplierContactGridView();
                    }

                    if (insightSupplierContactId != 0)
                    {
                        SaveInsightSupplierContactDistributionLink(insightSupplierContactId);
                    }

                    if (insightSupplierContactId != 0)
                    {
                        SaveInsightSupplierContactDistributionOption(insightSupplierContactId);
                    }

                    if (insightSupplierContactId != 0)
                    {
                        SaveInsightSupplierContactDistributionModel(insightSupplierContactId);
                    }

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSave":
                        Response.Redirect("InsightSupplierContactList.aspx");
                        break;

                    case "ButtonSaveEdit":
                        Response.Redirect(String.Format("InsightSupplierContactEdit.aspx?InsightSupplierContactId={0}&InsightSupplierId={1}", insightSupplierContact.InsightSupplierContactId, this.insightSupplierId));
                        break;

                    case "ButtonSaveNew":
                        Response.Redirect("InsightSupplierContactEdit.aspx");
                        break;

                    case "ButtonSaveLink":
                        Response.Redirect(String.Format("InsightSupplierContactEdit.aspx?InsightSupplierContactId={0}&InsightSupplierId={1}", 0, this.insightSupplierId));
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        ErrorMessage.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                }
            }
        }