Exemple #1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                ViewState["MaterialGroupID"] = ddlMaterialGroup.SelectedValue;
                ApplicationResult objResults    = new ApplicationResult();
                MaterialBO        objMaterialBO = new MaterialBO();
                MaterialBL        objMaterialBL = new MaterialBL();

                objMaterialBO.MaterialGroupID    = Convert.ToInt32(ddlMaterialGroup.SelectedValue);
                objMaterialBO.TrustMID           = Convert.ToInt32(Session[ApplicationSession.TRUSTID]);
                objMaterialBO.SchoolMID          = 0;
                objMaterialBO.UOMID              = Convert.ToInt32(ddlUOM.SelectedValue);
                objMaterialBO.MaterialCode       = txtMaterialCode.Text;
                objMaterialBO.MaterialName       = txtMaterialName.Text;
                objMaterialBO.Description        = txtDescription.Text;
                objMaterialBO.ModelNo            = txtModelNo.Text;
                objMaterialBO.LastModifiedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                objMaterialBO.LastModifiedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                int intValidate = 0;

                if (ViewState["Mode"].ToString() == "Save")
                {
                    objMaterialBO.CreatedDate   = DateTime.UtcNow.AddHours(5.5).ToString();
                    objMaterialBO.CreatedUserID = Convert.ToInt32(Session[ApplicationSession.USERID]);
                    objResults = objMaterialBL.Material_Insert(objMaterialBO);
                    if (objResults != null)
                    {
                        if (objResults.resultDT.Rows.Count > 0)
                        {
                            intValidate = Convert.ToInt32(objResults.resultDT.Rows[0]["MaterialValidate"]);
                        }
                    }
                }
                else if (ViewState["Mode"].ToString() == "Edit")
                {
                    objMaterialBO.MaterialID = Convert.ToInt32(ViewState["MaterialID"].ToString());
                    objResults = objMaterialBL.Material_Update(objMaterialBO);
                    if (objResults.resultDT.Rows.Count > 0)
                    {
                        intValidate = Convert.ToInt32(objResults.resultDT.Rows[0]["MaterialValidate"]);
                    }
                }
                if (intValidate == 1)
                {
                    txtMaterialName.Text = "";
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Material Name is already exist.');</script>");
                }
                else if (intValidate == 2)
                {
                    txtMaterialCode.Text = "";
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Material Code already exist.');</script>");
                }
                else if (intValidate == 3)
                {
                    if (ViewState["Mode"].ToString() == "Save")
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='javascript'>alert('Material Created Successfully.');</script>");
                    }
                    else if (ViewState["Mode"].ToString() == "Edit")
                    {
                        ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script language='JavaScript'>alert('Material updated successfully.');</script>");
                    }
                    setVisibility();
                }
                else if (intValidate == 4)
                {
                    ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error", ex);
                ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical issue. Please Contact to your administrator.');</script>");
            }
        }
        /*
         * public async override Task<IPricingInputDocumentBase> PrepareInputDocumentAsync(PricingParameters pricingParameters)
         * {
         *  this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync - count " + (pricingParameters.Conditions.Count()));
         *  var inputDocument = await base.PrepareInputDocumentAsync(pricingParameters);
         *
         *  IEnumerator<DocumentCondBO> enumerator = pricingParameters.Conditions.GetEnumerator();
         *  try
         *  {
         *      while (enumerator.MoveNext())
         *      {
         *          DocumentCondBO current = enumerator.Current;
         *          this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync " + current.DealConditionNumber);
         *          this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync " + current.ConditionType);
         *          this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync " + current.ItemNumber);
         *          this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync " + current.PromotionDiscount);
         *          this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync " + current.PercentageType);
         *          this.LogDebug("*** ZPricingManager:PrepareInputDocumentAsync " + current.Amount + " " + current.Currency);
         *
         *      }
         *  }
         *  catch {
         *
         *  }
         *
         *  return inputDocument;
         * }
         */

        public override void FillInputDocumentItem(IPricingInputDocumentBase inputDocument, IDocumentItemEntity documentItem, ActivityEntity activity, CustomizingSalesAreaBO customizingSalesArea, IList <MaterialBO> materials, IList <MaterialAltUomBO> materialAltUoms, IList <MaterialSalesOrgBO> materialSalesOrgs, IList <MaterialTaxBO> materialTaxes, CustomerSalesAreaBO customerSalesArea, CustomerBO customer, bool isRunningOnIsoCode, IList <DocumentCondBO> conditionsForItems, IDictionary <string, string> materialCampaigns, IDictionary <string, string> physicalUnitDictionary, IDictionary <string, CustomizingBO> reasonCodesCustomizingDictionary)
        {
            IPricingInputDocumentItemBase inputItem = inputDocument.AddItem(documentItem.DocumentItemNumber, documentItem.MaterialNumber);

            inputItem.AddAttribute("SHKZG", (object)documentItem.IsReturn.ToAbapString());
            inputItem.AddAttribute("RETPO", (object)documentItem.IsReturn.ToAbapString());
            string str1 = activity.ActivityType == SAPCD.DSD.MobileClient.Business.Objects.Common.Enums.ActivityType.FreeGoodsDelivery || activity.ActivityType == SAPCD.DSD.MobileClient.Business.Objects.Common.Enums.ActivityType.FreeGoodsOrder ? this.DeterminePricingIndicatorForFGDocument(activity, documentItem, customizingSalesArea) : this.DeterminePricingIndicator(documentItem, reasonCodesCustomizingDictionary);

            inputItem.AddAttribute("PRSFD", (object)str1);
            inputItem.AddAttribute("IS_EMPTIES_ITEM", (object)documentItem.IsUntiedEmpty.ToAbapString());
            MaterialBO material = materials.First <MaterialBO>((Func <MaterialBO, bool>)(m => m.MaterialNumber == documentItem.MaterialNumber));

            inputItem.AddMaterialInfo(material);
            inputItem.AddQuantities(documentItem);
            inputItem.AddCustomerSalesAreaInfo(customerSalesArea, customer);
            MaterialSalesOrgBO materialSalesOrg = materialSalesOrgs.First <MaterialSalesOrgBO>((Func <MaterialSalesOrgBO, bool>)(m => m.MaterialNumber == documentItem.MaterialNumber));

            inputItem.AddMaterialSalesAreaInfo(materialSalesOrg);


            this.AddAltUoms(inputItem, documentItem.MaterialNumber, (IEnumerable <MaterialAltUomBO>)materialAltUoms, isRunningOnIsoCode, physicalUnitDictionary);
            string uom       = !isRunningOnIsoCode ? documentItem.ActualUnitOfMeasure : this.ConvertToCommercialCode(documentItem.ActualUnitOfMeasure, physicalUnitDictionary);
            string volumeUom = !isRunningOnIsoCode ? material.VolumeUom : this.ConvertToCommercialCode(material.VolumeUom, physicalUnitDictionary);
            string weightUom = !isRunningOnIsoCode ? material.WeightUom : this.ConvertToCommercialCode(material.WeightUom, physicalUnitDictionary);
            string baseUom   = !isRunningOnIsoCode ? material.BaseUom : this.ConvertToCommercialCode(material.BaseUom, physicalUnitDictionary);

            inputItem.AddUoms(uom, volumeUom, weightUom, baseUom);

            if (conditionsForItems != null)
            {
                IEnumerable <DocumentCondBO> documentCondBos = conditionsForItems.Where <DocumentCondBO>((Func <DocumentCondBO, bool>)(x => x.ItemNumber == inputItem.ItemId));

                if (documentCondBos != null)
                {
                    /*
                     * this.LogDebug("*** ZPricingManager:FillInputDocumentItem - count " + (documentCondBos.Count()));
                     *
                     * if (documentCondBos.Count() > 1)
                     * {
                     *  throw new PricingException("No es permitido mas de una condición de ventas activa para el mismo producto [" + material.MaterialNumber + "]");
                     * }
                     */

                    // Add Manual conditions
                    IEnumerator <DocumentCondBO> enumerator = documentCondBos.GetEnumerator();
                    try
                    {
                        // This loop will assume there is only one deal condition applied to this line item
                        while (enumerator.MoveNext())
                        {
                            DocumentCondBO current = enumerator.Current;
                            inputItem.AddManualCondRecord(current.ConditionType, current.Amount, current.Currency);
                        }
                    }
                    finally
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                }
            }

            // Add DC type to be used by routine 959
            if (lineItemConditionMet.TryGetValue(inputItem.ItemId, out string conditionID))
            {
                if (dealConditionsMetList.TryGetValue(conditionID, out DealConditionHeaderBO dealConditionHeaderBO))
                {
                    this.LogDebug("*** ZPricingManager:FillInputDocumentItem - Add contition type for " + inputItem.ItemId + "/" + dealConditionHeaderBO.DealConditionID + "/" + dealConditionHeaderBO.DealConditionType);
                    inputItem.AddAttribute("ZZTYPE", dealConditionHeaderBO.DealConditionType);  // value to be used by routine 959.
                }
            }

            /*
             * MaterialTaxBO materialTax = materialTaxes.FirstOrDefault<MaterialTaxBO>((Func<MaterialTaxBO, bool>)(mt =>
             * {
             * if (mt.MaterialNumber == documentItem.MaterialNumber)
             *     return mt.Country == customer.Country;
             * return false;
             * }));
             */

            MaterialTaxBO materialTax = materialTaxes.FirstOrDefault <MaterialTaxBO>((Func <MaterialTaxBO, bool>)
                                                                                         (mt => ((mt.MaterialNumber == documentItem.MaterialNumber) && (mt.Country == customer.Country))));

            if (materialTax != null)
            {
                this.LogDebug("*** ZPricingManager:FillInputDocumentItem-CustomerCountry - " + materialTax.Country);
                this.LogDebug("*** ZPricingManager:FillInputDocumentItem-TAXM1 - " + materialTax.TaxClass1);
                this.LogDebug("*** ZPricingManager:FillInputDocumentItem-TAXM2 - " + materialTax.TaxClass2);
                this.LogDebug("*** ZPricingManager:FillInputDocumentItem-TAXM3 - " + materialTax.TaxClass3);
                inputItem.AddMaterialTaxInfo(materialTax);
            }

            string str2;

            if (materialCampaigns.TryGetValue(documentItem.MaterialNumber, out str2))
            {
                inputItem.AddAttribute("CMPGN_ID", (object)str2);
            }
            else
            {
                inputItem.AddAttribute("CMPGN_ID", (object)string.Empty);
            }
            inputItem.AddAttribute("SDATE", (object)DateTime.Now);

            try
            {
                if (MaterialExt.Count > 0)
                {
                    FieldExtensionBO fieldExtension = MaterialExt.FirstOrDefault <FieldExtensionBO>((Func <FieldExtensionBO, bool>)(m => m.ElementKey == documentItem.MaterialNumber));

                    if (fieldExtension != null)
                    {
                        this.LogDebug("ZZIIEE: " + fieldExtension.ElementKey + "=" + fieldExtension.Value);
                        inputItem.AddAttribute("ZZIIEE", fieldExtension.Value);
                    }
                }

                if (materialSalesOrg.ProductHierarchy.Length > 7)
                {
                    string prdh4 = materialSalesOrg.ProductHierarchy.Substring(6, 2);
                    inputItem.AddAttribute("ZZPRODH4", prdh4);
                }

                inputItem.AddAttribute("ZZMVGR1_P", materialSalesOrg.MaterialGroup1);
                inputItem.AddAttribute("ZZMVGR2_P", materialSalesOrg.MaterialGroup2);
                inputItem.AddAttribute("ZZMVGR3_P", materialSalesOrg.MaterialGroup3);
                inputItem.AddAttribute("UPMAT", material.MaterialNumber);
            }
            catch (Exception ex)
            {
                this.LogError("ZPricingManager:FillInputDocumentItem - Linea " + inputItem.ItemId + " Material: " + material.MaterialNumber, ex);
            }


            /*
             * if (inputDocument.GetStringHeaderAttribute("HIENR") != null)
             * {
             *  inputDocument.AddAttribute("HIENR", inputDocument.GetStringHeaderAttribute("HIENR01"));
             * }
             *
             * /*
             * if (inputDocument.GetStringHeaderAttribute("HIENR02") != null)
             * {
             *  inputDocument.AddAttribute("HIENR46", inputDocument.GetStringHeaderAttribute("HIENR02"));
             * }
             */

            //this.LogDebug("*** ZPricingManager:FillInputDocumentItemHIENR03 - " + inputItem.GetStringAttribute("HIENR03"));
            //this.LogDebug("*** ZPricingManager:FillInputDocumentItemPMATN - " + inputItem.GetStringAttribute("PMATN"));
        }
Exemple #3
0
        public ApiResponse <int> Update(MaterialBO bo)
        {
            var rows = this.Service.Update(bo);

            return(new ApiResponse <int>(ResponseCode.Ok, rows));
        }
Exemple #4
0
        /// <summary>
        /// To Update details of Material in tbl_Material_M table
        /// Created By : Chintan, 10/13/2014
        /// Modified By :
        /// </summary>
        /// <param name="objMaterialBO"></param>
        /// <returns></returns>
        public ApplicationResult Material_Update(MaterialBO objMaterialBO)
        {
            try
            {
                pSqlParameter = new SqlParameter[14];


                pSqlParameter[0]           = new SqlParameter("@MaterialID", SqlDbType.Int);
                pSqlParameter[0].Direction = ParameterDirection.Input;
                pSqlParameter[0].Value     = objMaterialBO.MaterialID;

                pSqlParameter[1]           = new SqlParameter("@MaterialGroupID", SqlDbType.Int);
                pSqlParameter[1].Direction = ParameterDirection.Input;
                pSqlParameter[1].Value     = objMaterialBO.MaterialGroupID;

                pSqlParameter[2]           = new SqlParameter("@TrustMID", SqlDbType.Int);
                pSqlParameter[2].Direction = ParameterDirection.Input;
                pSqlParameter[2].Value     = objMaterialBO.TrustMID;

                pSqlParameter[3]           = new SqlParameter("@SchoolMID", SqlDbType.Int);
                pSqlParameter[3].Direction = ParameterDirection.Input;
                pSqlParameter[3].Value     = objMaterialBO.SchoolMID;

                pSqlParameter[4]           = new SqlParameter("@UOMID", SqlDbType.Int);
                pSqlParameter[4].Direction = ParameterDirection.Input;
                pSqlParameter[4].Value     = objMaterialBO.UOMID;

                pSqlParameter[5]           = new SqlParameter("@MaterialCode", SqlDbType.VarChar);
                pSqlParameter[5].Direction = ParameterDirection.Input;
                pSqlParameter[5].Value     = objMaterialBO.MaterialCode;

                pSqlParameter[6]           = new SqlParameter("@MaterialName", SqlDbType.VarChar);
                pSqlParameter[6].Direction = ParameterDirection.Input;
                pSqlParameter[6].Value     = objMaterialBO.MaterialName;

                pSqlParameter[7]           = new SqlParameter("@Description", SqlDbType.VarChar);
                pSqlParameter[7].Direction = ParameterDirection.Input;
                pSqlParameter[7].Value     = objMaterialBO.Description;

                pSqlParameter[8]           = new SqlParameter("@ModelNo", SqlDbType.VarChar);
                pSqlParameter[8].Direction = ParameterDirection.Input;
                pSqlParameter[8].Value     = objMaterialBO.ModelNo;

                pSqlParameter[9]           = new SqlParameter("@IsDeleted", SqlDbType.Int);
                pSqlParameter[9].Direction = ParameterDirection.Input;
                pSqlParameter[9].Value     = objMaterialBO.IsDeleted;

                pSqlParameter[10]           = new SqlParameter("@CreatedDate", SqlDbType.VarChar);
                pSqlParameter[10].Direction = ParameterDirection.Input;
                pSqlParameter[10].Value     = objMaterialBO.CreatedDate;

                pSqlParameter[11]           = new SqlParameter("@CreatedUserID", SqlDbType.Int);
                pSqlParameter[11].Direction = ParameterDirection.Input;
                pSqlParameter[11].Value     = objMaterialBO.CreatedUserID;

                pSqlParameter[12]           = new SqlParameter("@LastModifiedDate", SqlDbType.VarChar);
                pSqlParameter[12].Direction = ParameterDirection.Input;
                pSqlParameter[12].Value     = objMaterialBO.LastModifiedDate;

                pSqlParameter[13]           = new SqlParameter("@LastModifiedUserID", SqlDbType.Int);
                pSqlParameter[13].Direction = ParameterDirection.Input;
                pSqlParameter[13].Value     = objMaterialBO.LastModifiedUserID;


                sSql = "usp_tbl_Material_M_Update";
                DataTable dtResult = new DataTable();
                dtResult = Database.ExecuteDataTable(CommandType.StoredProcedure, sSql, pSqlParameter);
                ApplicationResult objResults = new ApplicationResult(dtResult);
                objResults.status = ApplicationResult.CommonStatusType.SUCCESS;
                return(objResults);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                objMaterialBO = null;
            }
        }
Exemple #5
0
        public ApiResponse <int?> Create(MaterialBO bo)
        {
            var id = this.Service.Add(bo);

            return(new ApiResponse <int?>(ResponseCode.Ok, id));
        }