Exemple #1
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                bool hasError = false;
                LabelError.Text = "";

                hasError = RulesGeneral();

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

                switch (Convert.ToInt32(DropDownListClaimType.SelectedValue))
                {
                case 1:    //Expired Stock
                {
                    hasError = RulesExpiredStock();
                    break;
                }

                case 2:    //Factory Fault
                {
                    hasError = RulesFactoryFault();
                    break;
                }

                case 3:    //DemoPromo
                {
                    hasError = RulesDemoPromo();
                    break;
                }

                case 4:    //Recall
                {
                    hasError = RulesRecall();
                    break;
                }

                default:
                {
                    hasError = RulesGeneralLimit();
                    break;
                }
                }

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

                string claimNumber           = (TextBoxClaimNumber.Text.Length == 0) ? "Voucher" : TextBoxClaimNumber.Text;
                int    claimSkuCategoryId    = (DropDownListCategory.SelectedValue == "0" && DropDownListClaimType.SelectedValue == "14" /*Voucher*/) ? 34 /*Store Space*/ : Convert.ToInt32(DropDownListCategory.SelectedValue);
                int    claimSkuSubCategoryId = ((DropDownListSubCategory.SelectedValue == "0" || DropDownListSubCategory.SelectedValue == "") && DropDownListClaimType.SelectedValue == "14" /*Voucher*/) ? 169 /*Store Space - Default*/: Convert.ToInt32(DropDownListSubCategory.SelectedValue);

                StoreRep.Web.Code.Claim claim = new StoreRep.Web.Code.Claim();

                claim.ClaimId               = this.claimId;
                claim.KeyAccountId          = (Convert.ToInt32(DropDownListSupplier.SelectedValue) == 2) ? Convert.ToInt32(DropDownListKeyAccount.SelectedValue) : 0;
                claim.ClaimSupplierId       = Convert.ToInt32(DropDownListSupplier.SelectedValue);
                claim.StoreId               = Convert.ToInt32(DropDownListStore.SelectedValue);
                claim.ClaimDate             = Convert.ToDateTime(TextBoxClaimDate.Text);
                claim.ClaimNumber           = claimNumber;
                claim.ClaimTypeId           = Convert.ToInt32(DropDownListClaimType.SelectedValue);
                claim.ClaimResponsibleId    = Convert.ToInt32(DropDownListClaimResponsible.SelectedValue);
                claim.ClaimSkuCategoryId    = claimSkuCategoryId;
                claim.ClaimSkuSubCategoryId = claimSkuSubCategoryId;
                claim.Value          = Convert.ToDecimal(TextBoxValue.Text);
                claim.Quantity       = (TextBoxQuantity.Text.Length > 0) ? Convert.ToDecimal(TextBoxQuantity.Text) : 0;//Convert.ToDecimal(TextBoxQuantity.Text);//(Convert.ToInt32(DropDownListClaimType.SelectedValue) == 4) ? Convert.ToDecimal(TextBoxQuantity.Text) : 0;
                claim.Comment        = (TextBoxComment.Text.Length > 0) ? TextBoxComment.Text : "";
                claim.ModifiedUser   = this.Master.LoggedOnAccount;
                claim.AccountId      = (Account.GetAccountByUserName(Page.User.Identity.Name.ToString()).AccountId);
                claim.ClaimReference = (TextBoxClaimReference.Text.Length > 0) ? TextBoxClaimReference.Text : "";
                claim.BatchNumber    = (TextBoxBatchNumber.Text.Length > 0) ? TextBoxBatchNumber.Text : "";

                /*
                 * PayStore - 0 = No
                 * PayStore - 1 = Yes
                 * PayStore - 99 = Not indicated yet
                 */
                claim.PayStore = (RadioButtonPayStoreYes.Checked) ? 1 : 0;

                /*
                 * SupplierClaimBack - 0 = No
                 * SupplierClaimBack - 1 = Yes
                 * SupplierClaimBack - 99 = Not indicated yet
                 */
                claim.SupplierClaimBack = (RadioButtonClaimSupplierYes.Checked) ? 1 : 0;

                try
                {
                    claim.Save();
                    int claimId = claim.ClaimId;

                    ClaimPaymentNotification(claimId);

                    Button clickedButton = (Button)sender;
                    switch (clickedButton.ID)
                    {
                    case "ButtonSaveList":
                        Response.Redirect(String.Format("ClaimList.aspx?ClaimId={0}", claim.ClaimId));
                        //Response.Redirect(String.Format("ClaimScheduleEdit.aspx?ClaimNumber={0}&ClaimStoreId={1}&ClaimDate={2}&Supplier={3}", claim.ClaimNumber, claim.StoreId, claim.ClaimDate, claim.Supplier));
                        break;

                    case "ButtonSaveNew":
                        //Response.Redirect(String.Format("ClaimEdit.aspx?StoreId={0}&ClaimId={1}&CompanyId={2}&Supplier={3}", Convert.ToInt32(DropDownListStore.SelectedValue), claim.ClaimId, this.accountId, claim.Supplier));
                        //Response.Redirect("ClaimEdit.aspx");
                        Reset();
                        break;
                    }
                }
                catch (System.Data.SqlClient.SqlException sqlEx)
                {
                    LabelError.Text = "";
                    for (int i = 0; i < sqlEx.Errors.Count; i++)
                    {
                        LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                    }
                    PanelError.Visible      = true;
                    PanelErrorSpace.Visible = true;
                }
            }
        }
Exemple #2
0
        private void BindClaim()
        {
            try
            {
                StoreRep.Web.Code.Claim claim = StoreRep.Web.Code.Claim.GetClaimByClaimId(this.claimId);

                /*
                 * PayStore - 0 = No
                 * PayStore - 1 = Yes
                 * PayStore - 99 = Not indicated yet
                 */
                RadioButtonPayStoreNo.Checked  = claim.PayStore == 0;
                RadioButtonPayStoreYes.Checked = claim.PayStore == 1;

                /*
                 * SupplierClaimBack - 0 = No
                 * SupplierClaimBack - 1 = Yes
                 * SupplierClaimBack - 99 = Not indicated yet
                 */
                RadioButtonClaimSupplierNo.Checked  = claim.SupplierClaimBack == 0;
                RadioButtonClaimSupplierYes.Checked = claim.SupplierClaimBack == 1;

                DropDownListSupplier.ClearSelection();
                DropDownListSupplier.Items.FindByValue(claim.ClaimSupplierId.ToString()).Selected = true;

                //BindStore();
                DropDownListStore.ClearSelection();
                DropDownListStore.Items.FindByValue(claim.StoreId.ToString()).Selected = true;

                TextBoxClaimDate.Text   = claim.FormattedClaimDateEdit.ToString();
                TextBoxClaimNumber.Text = claim.ClaimNumber;

                DropDownListClaimType.ClearSelection();
                DropDownListClaimType.Items.FindByValue(claim.ClaimTypeId.ToString()).Selected = true;

                DropDownListClaimResponsible.ClearSelection();
                DropDownListClaimResponsible.Items.FindByValue(claim.ClaimResponsibleId.ToString()).Selected = true;

                DropDownListCategory.ClearSelection();
                DropDownListCategory.Items.FindByValue(claim.ClaimSkuCategoryId.ToString()).Selected = true;
                BindClaimSkuSubCategory();
                DropDownListSubCategory.ClearSelection();
                DropDownListSubCategory.Items.FindByValue(claim.ClaimSkuSubCategoryId.ToString()).Selected = true;

                TextBoxValue.Text = claim.Value.ToString();

                //PanelQuantity.Visible = Convert.ToInt32(DropDownListClaimType.SelectedValue) == 4; //Recall

                if (Convert.ToInt32(DropDownListClaimType.SelectedValue) == 4)//Recall
                {
                    PanelBatchNumber.Visible = true;
                    TextBoxBatchNumber.Text  = claim.BatchNumber;
                }
                else
                {
                    PanelBatchNumber.Visible = true;
                    TextBoxBatchNumber.Text  = "";
                }

                TextBoxQuantity.Text = claim.Quantity.ToString();

                TextBoxComment.Text        = claim.Comment;
                TextBoxClaimReference.Text = claim.ClaimReference;

                TextBoxCaptureDate.Text = String.Format("{0:d/M/yyyy HH:mm:ss}", claim.CreatedDate);
                TextBoxCapturedBy.Text  = claim.ModifiedUser;

                if (Convert.ToInt32(DropDownListSupplier.SelectedValue) == 2) //Monteagle Africa
                {
                    PanelKeyAccount.Visible = true;
                    DropDownListKeyAccount.ClearSelection();
                    DropDownListKeyAccount.Items.FindByValue(claim.KeyAccountId.ToString()).Selected = true;
                }
                else
                {
                    PanelKeyAccount.Visible = false;
                }

                BindClaimTypeSelection();
            }
            catch (System.Data.SqlClient.SqlException sqlEx)
            {
                for (int i = 0; i < sqlEx.Errors.Count; i++)
                {
                    LabelError.Text += (sqlEx.Errors[i].Message + "<br />");
                }
                PanelError.Visible = true;
            }
            catch (Exception exception)
            {
                LabelError.Text   += (exception.Message + "<br />");
                PanelError.Visible = true;
            }
        }