コード例 #1
0
        private void SavePRMSupplierItemMapEntity()
        {
            if (IsValid)
            {
                try
                {
                    IList <ListViewDataItem> list = lvPRMSupplierItemMap.Items;

                    if (list != null && list.Count > 0)
                    {
                        foreach (ListViewDataItem lvdi in list)
                        {
                            TextBox txtActualPriceValidation = (TextBox)lvdi.FindControl("txtActualPriceLV");
                            if (txtActualPriceValidation.Enabled)
                            {
                                Decimal ActualPrice, DiscountPercentage, Price;
                                Int64   ItemID, BrandID;

                                Label   lblItemIDLV             = (Label)lvdi.FindControl("txtItemIDLV");
                                Label   lblBrandIDLV            = (Label)lvdi.FindControl("lblBrandIDLV");
                                TextBox txtActualPriceLV        = (TextBox)lvdi.FindControl("txtActualPriceLV");
                                TextBox txtDiscountPercentageLV = (TextBox)lvdi.FindControl("txtDiscountPercentageLV");
                                TextBox txtPriceLV     = (TextBox)lvdi.FindControl("txtPriceLV");
                                TextBox txtEntryDateLV = (TextBox)lvdi.FindControl("txtEntryDateLV");

                                Int64.TryParse(lblItemIDLV.Text, out ItemID);
                                Int64.TryParse(lblBrandIDLV.Text, out BrandID);
                                Decimal.TryParse(txtActualPriceLV.Text.Trim(), out ActualPrice);
                                Decimal.TryParse(txtDiscountPercentageLV.Text.Trim(), out DiscountPercentage);

                                Decimal actualPrice, discountPercentages, price;

                                Decimal.TryParse(txtActualPriceLV.Text.Trim(), out actualPrice);
                                Decimal.TryParse(txtDiscountPercentageLV.Text.Trim(), out discountPercentages);

                                price = actualPrice - (actualPrice * (discountPercentages / 100));

                                String fe1 = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierItemMapEntity.FLD_NAME_SupplierID, ddlSupplierID.SelectedValue.ToString(), SQLMatchType.Equal);
                                String fe2 = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierItemMapEntity.FLD_NAME_ItemID, ItemID.ToString(), SQLMatchType.Equal);
                                String fe3 = SqlExpressionBuilder.PrepareFilterExpression(PRMSupplierItemMapEntity.FLD_NAME_BrandID, BrandID.ToString(), SQLMatchType.Equal);
                                String fe4 = SqlExpressionBuilder.PrepareFilterExpression(fe1, SQLJoinType.AND, fe2);
                                String fe  = SqlExpressionBuilder.PrepareFilterExpression(fe4, SQLJoinType.AND, fe3);
                                IList <PRMSupplierItemMapEntity> SupplierItemMapList = FCCPRMSupplierItemMap.GetFacadeCreate().GetIL(null, null, String.Empty, fe, DatabaseOperationType.LoadWithFilterExpression);

                                if (SupplierItemMapList != null && SupplierItemMapList.Count > 0)
                                {
                                    PRMSupplierItemMapEntity pRMSupplierItemMapEntity = SupplierItemMapList[0];
                                    pRMSupplierItemMapEntity.ActualPrice        = ActualPrice;
                                    pRMSupplierItemMapEntity.DiscountPercentage = DiscountPercentage;
                                    pRMSupplierItemMapEntity.Price  = price;
                                    pRMSupplierItemMapEntity.ItemID = ItemID;
                                    if (txtEntryDateLV.Text.Trim().IsNotNullOrEmpty())
                                    {
                                        pRMSupplierItemMapEntity.EntryDate = MiscUtil.ParseToDateTime(txtEntryDateLV.Text);
                                    }

                                    FCCPRMSupplierItemMap.GetFacadeCreate().Update(pRMSupplierItemMapEntity, fe, DatabaseOperationType.Update, TransactionRequired.No);
                                }
                            }
                        }
                        MiscUtil.ShowMessage(lblMessage, "Vendor Item Map Information has been updated successfully.", false);
                    }
                    BindPRMSupplierItemMapList();
                }
                catch (Exception ex)
                {
                    MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                }
            }
        }
コード例 #2
0
ファイル: MDBrand.ascx.cs プロジェクト: sriramsoftware/FATERP
        protected void lvMDBrand_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            Int64 BrandID;

            Int64.TryParse(e.CommandArgument.ToString(), out BrandID);

            if (BrandID > 0)
            {
                if (string.Equals(e.CommandName, "EditItem"))
                {
                    _BrandID = BrandID;

                    PrepareEditView();

                    cpeEditor.Collapsed   = false;
                    cpeEditor.ClientState = "false";
                }
                else if (string.Equals(e.CommandName, "DeleteItem"))
                {
                    try
                    {
                        Int64 result = -1;

                        String fe = SqlExpressionBuilder.PrepareFilterExpression(MDBrandEntity.FLD_NAME_BrandID, BrandID.ToString(), SQLMatchType.Equal);

                        MDBrandEntity mDBrandEntity = new MDBrandEntity();


                        result = FCCMDBrand.GetFacadeCreate().Delete(mDBrandEntity, fe, DatabaseOperationType.Delete, TransactionRequired.No);

                        if (result == 0)
                        {
                            _BrandID       = 0;
                            _MDBrandEntity = new MDBrandEntity();
                            PrepareInitialView();
                            BindMDBrandList();

                            MiscUtil.ShowMessage(lblMessage, "Brand has been successfully deleted.", true);
                        }
                        else
                        {
                            MiscUtil.ShowMessage(lblMessage, "Failed to delete Brand.", true);
                        }
                    }
                    catch (Exception ex)
                    {
                        MiscUtil.ShowMessage(lblMessage, ex.Message, true);
                    }
                }
            }
        }