public DiscountStructureMasterModel GetDiscountStructureByDSId(int dsid) { List <eSunSpeedDomain.DiscountStructureMasterModel> lstDS = new List <DiscountStructureMasterModel>(); eSunSpeedDomain.DiscountStructureMasterModel objDS; string Query = "SELECT * FROM DiscountStructure WHERE DS_ID=" + dsid; System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); dr.Read(); objDS = new DiscountStructureMasterModel(); objDS.Ds_id = Convert.ToInt32(dr["DS_Id"]); objDS.StructureName = dr["StructureName"].ToString(); objDS.SimpleDiscount = Convert.ToBoolean(dr["SimpleDiscount"]); objDS.CompoundDiscountwithSameNature = Convert.ToBoolean(dr["CD_withSameNature"]); objDS.CompoundDiscountDifferentNature = Convert.ToBoolean(dr["CD_DifferentNature"]); objDS.NoOfDiscounts = dr["NoOfDiscounts"] == null || dr["NoOfDiscounts"].ToString() == "" ? 0 : Convert.ToInt32(dr["NoOfDiscounts"]); objDS.SpecifyCaptionForDiscount = dr["SpecifyCaptionForDiscount"].ToString(); objDS.AbsoluteDiscount = Convert.ToBoolean(dr["AbsoluteAmount"]); objDS.PerMainQty = Convert.ToBoolean(dr["PerMainQty"]); objDS.Percentage = Convert.ToBoolean(dr["Percentage"]); objDS.PerAltQty = Convert.ToBoolean(dr["PerAltQty"]); objDS.ItemPrice = Convert.ToBoolean(dr["ItemPrice"]); objDS.ItemMRP = Convert.ToBoolean(dr["ItemMRP"]); objDS.ItemAmount = Convert.ToBoolean(dr["ItemAmount"]); objDS.ItemListPrice = Convert.ToBoolean(dr["ItemListPrice"]); return(objDS); }
//update public bool UpdateStructure(DiscountStructureMasterModel objDS) { string Query = string.Empty; bool isUpdate = true; try { DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@StructureName", objDS.StructureName)); paramCollection.Add(new DBParameter("@SimpleDiscount", objDS.SimpleDiscount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CD_withSameNature", objDS.CompoundDiscountwithSameNature, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CD_DifferentNature", objDS.CompoundDiscountDifferentNature, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@NoOfDiscounts", objDS.NoOfDiscounts)); paramCollection.Add(new DBParameter("@SpecifyCaptionForDiscount", objDS.SpecifyCaptionForDiscount)); paramCollection.Add(new DBParameter("@AbsoluteAmount", objDS.AbsoluteDiscount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@PerMainQty", objDS.PerMainQty, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@Percentage", objDS.Percentage, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@PerAltQty", objDS.PerAltQty, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemPrice", objDS.ItemPrice, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemMRP", objDS.ItemMRP, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemAmount", objDS.ItemAmount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemListPrice", objDS.ItemListPrice, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ModifiedBy", "Admin")); paramCollection.Add(new DBParameter("@DS_Id", objDS.Ds_id)); Query = "UPDATE DiscountStructure SET [SimpleDiscount]=@SimpleDiscount,[CD_withSameNature]=@CompoundDiscountwithSameNature,[CD_DifferentNature]=@CompoundDiscountDifferentNature,[NoOfDiscounts]=@NoOfDiscounts,[SpecifyCaptionForDiscount]=@SpecifyCaptionForDiscount,[AbsoluteAmount]=@AbsoluteAmount," + "[PerMainQty]=@PerMainQty,[Percentage]=@Percentage,[PerAltQty]=@PerAltQty,[ItemPrice]=@ItemPrice," + "[ItemMRP]=@ItemMRP,[ItemAmount]=@ItemAmount,[ItemListPrice]=@ItemListPrice,[ModifiedBy]=@ModifiedBy " + "WHERE DS_Id=@DS_Id"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isUpdate = true; } } catch (Exception ex) { isUpdate = false; throw ex; } return(isUpdate); }
public bool SaveStructure(DiscountStructureMasterModel objDS) { string Query = string.Empty; bool isSaved = true; try { DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@StructureName", objDS.StructureName)); paramCollection.Add(new DBParameter("@SimpleDiscount", Convert.ToBoolean(objDS.SimpleDiscount), System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CompoundDiscountwithSameNature", objDS.CompoundDiscountwithSameNature, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CompoundDiscountDifferentNature", objDS.CompoundDiscountDifferentNature, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@NoOfDiscounts", objDS.NoOfDiscounts, System.Data.DbType.Int32)); paramCollection.Add(new DBParameter("@SpecifyCaptionForDiscount", objDS.SpecifyCaptionForDiscount)); paramCollection.Add(new DBParameter("@AbsoluteAmount", objDS.AbsoluteDiscount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@PerMainQty", objDS.PerMainQty, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@Percentage", objDS.Percentage, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@PerAltQty", objDS.PerAltQty, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemPrice", objDS.ItemPrice, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemMRP", objDS.ItemMRP, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemAmount", objDS.ItemAmount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemListPrice", objDS.ItemListPrice, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CreatedBy", objDS.CreatedBy)); Query = "INSERT INTO DiscountStructure ([StructureName],[SimpleDiscount],[CD_withSameNature]," + "[CD_DifferentNature],[NoOfDiscounts],[SpecifyCaptionForDiscount],[AbsoluteAmount],[PerMainQty]," + "[Percentage],[PerAltQty],[ItemPrice],[ItemMRP],[ItemAmount],[ItemListPrice],[CreatedBy]) " + "VALUES(@StructureName,@SimpleDiscount,@CompoundDiscountwithSameNature,@CompoundDiscountDifferentNature," + "@NoOfDiscounts,@SpecifyCaptionForDiscount,@AbsoluteAmount,@PerMainQty,@Percentage,@PerAltQty,@ItemPrice," + "@ItemMRP,@ItemAmount,@ItemListPrice,@CreatedBy)"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isSaved = true; } } catch (Exception ex) { isSaved = false; throw ex; } return(isSaved); }
public bool SaveStructure(DiscountStructureMasterModel objDS) { string Query = string.Empty; bool isSaved = true; try { DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@StructureName", objDS.StructureName)); paramCollection.Add(new DBParameter("@SimpleDiscount", Convert.ToBoolean(objDS.SimpleDiscount), System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CompoundDiscountwithSameNature", objDS.CompoundDiscountwithSameNature, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CompoundDiscountDifferentNature", objDS.CompoundDiscountDifferentNature, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@NoOfDiscounts", objDS.NoOfDiscounts, System.Data.DbType.Int32)); paramCollection.Add(new DBParameter("@SpecifyCaptionForDiscount", objDS.SpecifyCaptionForDiscount)); paramCollection.Add(new DBParameter("@AbsoluteAmount", objDS.AbsoluteDiscount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@PerMainQty", objDS.PerMainQty, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@Percentage", objDS.Percentage, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@PerAltQty", objDS.PerAltQty, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemPrice", objDS.ItemPrice, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemMRP", objDS.ItemMRP, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemAmount", objDS.ItemAmount, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@ItemListPrice", objDS.ItemListPrice, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CreatedBy", objDS.CreatedBy)); System.Data.IDataReader dr = _dbHelper.ExecuteDataReader("spInsertDiscountStructure", _dbHelper.GetConnObject(), paramCollection, System.Data.CommandType.StoredProcedure); int id = 0; dr.Read(); id = Convert.ToInt32(dr[0]); SaveAccountPosting(objDS.ListofAccountPosting, id); } catch (Exception ex) { isSaved = false; throw ex; } return(isSaved); }
private void btnSave_Click(object sender, EventArgs e) { DiscountStructureMasterModel objdiscount = new DiscountStructureMasterModel(); objdiscount.StructureName = tbxStrName.Text.Trim() == null ? string.Empty : tbxStrName.Text.Trim(); objdiscount.SimpleDiscount = false; objdiscount.CompoundDiscountwithSameNature = false; objdiscount.CompoundDiscountDifferentNature = false; if (rbnDiscountType.SelectedIndex == 0) { objdiscount.SimpleDiscount = true; } if (rbnDiscountType.SelectedIndex == 1) { objdiscount.CompoundDiscountwithSameNature = true; } if (rbnDiscountType.SelectedIndex == 2) { objdiscount.CompoundDiscountDifferentNature = true; } objdiscount.NoOfDiscounts = Convert.ToInt32(tbxNoDiscounts.Text.Trim() == null ?"0": tbxNoDiscounts.Text.Trim()); objdiscount.AbsoluteDiscount = false; objdiscount.PerMainQty = false; objdiscount.Percentage = false; objdiscount.PerAltQty = false; if (rbnAccountDiscount.SelectedIndex == 0) { objdiscount.AbsoluteDiscount = true; } if (rbnAccountDiscount.SelectedIndex == 1) { objdiscount.PerMainQty = true; } if (rbnAccountDiscount.SelectedIndex == 2) { objdiscount.Percentage = true; } if (rbnAccountDiscount.SelectedIndex == 3) { objdiscount.PerAltQty = true; } objdiscount.ItemPrice = false; objdiscount.ItemMRP = false; objdiscount.ItemAmount = false; objdiscount.ItemPrice = false; if (rbnPercentage.SelectedIndex == 0) { objdiscount.ItemPrice = true; } if (rbnPercentage.SelectedIndex == 1) { objdiscount.ItemMRP = true; } if (rbnPercentage.SelectedIndex == 2) { objdiscount.ItemAmount = true; } if (rbnPercentage.SelectedIndex == 3) { objdiscount.ItemPrice = true; } objdiscount.SpecifyCaptionForDiscount = tbxCaptionDiscount.Text.Trim() == null ? string.Empty : tbxCaptionDiscount.Text.Trim(); DSAccountPosting objdsAccount; List <DSAccountPosting> lstAccountPost = new List <DSAccountPosting>(); for (int i = 0; i < dvgDisscountStrDetails.DataRowCount; i++) { DataRow row = dvgDisscountStrDetails.GetDataRow(i); objdsAccount = new DSAccountPosting(); objdsAccount.AccountPost = Convert.ToBoolean(row["AccountPost"].ToString() == "Y"?true:false); objdsAccount.AccountHeadPost = row["AccountHeadPost"].ToString() == null ? string.Empty : row["AccountHeadPost"].ToString(); objdsAccount.AffectsGoods = Convert.ToBoolean(row["AffectsGoods"].ToString() == "Y"?true:false); lstAccountPost.Add(objdsAccount); } objdiscount.ListofAccountPosting = lstAccountPost; bool IsSaved = objDisBL.SaveStructure(objdiscount); if (IsSaved) { MessageBox.Show("Saved Sussfully"); } }