public List <DSAccountPosting> GetAccountPostingDetails() { List <DSAccountPosting> lstDS = new List <DSAccountPosting>(); DSAccountPosting objDS; int DS_Id = GetDiscountStructId(); string Query = string.Format("SELECT * FROM DS_AccountPosting WHERE DS_Id={0}", DS_Id); System.Data.IDataReader dr = _dbHelper.ExecuteDataReader(Query, _dbHelper.GetConnObject()); while (dr.Read()) { objDS = new DSAccountPosting(); objDS.AccPost_Id = Convert.ToInt32(dr["AccPost_Id"]); objDS.DS_Id = Convert.ToInt32(dr["DS_Id"]); objDS.AccountHeadPost = dr["AccountHeadPost"].ToString(); objDS.AffectsGoods = Convert.ToBoolean(dr["AffectsGoods"]); objDS.AccountPost = Convert.ToBoolean(dr["AccountPosting"]); lstDS.Add(objDS); } return(lstDS); }
public bool SaveAccountPosting(DSAccountPosting objDSPosting) { string Query = string.Empty; bool isSaved = true; try { objDSPosting.DS_Id = GetDiscountStructId(); DBParameterCollection paramCollection = new DBParameterCollection(); paramCollection.Add(new DBParameter("@DS_Id", objDSPosting.DS_Id)); paramCollection.Add(new DBParameter("@AccountPosting", objDSPosting.AccountPost, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@AccountHeadPost", objDSPosting.AccountHeadPost)); paramCollection.Add(new DBParameter("@AffectsGoods", objDSPosting.AffectsGoods, System.Data.DbType.Boolean)); paramCollection.Add(new DBParameter("@CreatedBy", objDSPosting.CreatedBy)); Query = "INSERT INTO DS_AccountPosting ([DS_Id],[AccountPosting],[AccountHeadPost]," + "[AffectsGoods],[CreatedBy]) " + "VALUES(@DS_Id,@AccountPosting,@AccountHeadPost,@AffectsGoods," + "@CreatedBy)"; if (_dbHelper.ExecuteNonQuery(Query, paramCollection) > 0) { isSaved = true; } } catch (Exception ex) { isSaved = false; throw ex; } return(isSaved); }
private void btnSave_Click(object sender, EventArgs e) { MarkupStructureMasterModel objmarkup = new MarkupStructureMasterModel(); objmarkup.StructureName = tbxStrName.Text.Trim() == null ? string.Empty : tbxStrName.Text.Trim(); objmarkup.SimpleDiscount = false; objmarkup.CompoundMarkupwithSameNature = false; objmarkup.CompoundMarkupDifferentNature = false; if (rbnMarkupType.SelectedIndex == 0) { objmarkup.SimpleDiscount = true; } if (rbnMarkupType.SelectedIndex == 1) { objmarkup.CompoundMarkupwithSameNature = true; } if (rbnMarkupType.SelectedIndex == 2) { objmarkup.CompoundMarkupDifferentNature = true; } objmarkup.NoOfMarkups = Convert.ToInt32(tbxNoDiscounts.Text.Trim() == null ?"0": tbxNoDiscounts.Text.Trim()); objmarkup.AbsoluteDiscount = false; objmarkup.PerMainQty = false; objmarkup.Percentage = false; objmarkup.PerAltQty = false; if (rbnAccountMarkup.SelectedIndex == 0) { objmarkup.AbsoluteDiscount = true; } if (rbnAccountMarkup.SelectedIndex == 1) { objmarkup.PerMainQty = true; } if (rbnAccountMarkup.SelectedIndex == 2) { objmarkup.Percentage = true; } if (rbnAccountMarkup.SelectedIndex == 3) { objmarkup.PerAltQty = true; } objmarkup.ItemPrice = false; objmarkup.ItemMRP = false; objmarkup.ItemAmount = false; objmarkup.ItemPrice = false; if (rbnPercentage.SelectedIndex == 0) { objmarkup.ItemPrice = true; } if (rbnPercentage.SelectedIndex == 1) { objmarkup.ItemMRP = true; } if (rbnPercentage.SelectedIndex == 2) { objmarkup.ItemAmount = true; } if (rbnPercentage.SelectedIndex == 3) { objmarkup.ItemPrice = true; } objmarkup.SpecifyCaptionForMarkup = tbxCaptionMarkup.Text.Trim() == null ? string.Empty : tbxCaptionMarkup.Text.Trim(); DSAccountPosting objdsAccount; List <DSAccountPosting> lstAccountPost = new List <DSAccountPosting>(); for (int i = 0; i < dvgMarkupStrDetails.DataRowCount; i++) { DataRow row = dvgMarkupStrDetails.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); } objmarkup.ListofAccountPosting = lstAccountPost; bool IsSaved = objMakBL.SaveMarkupStructure(objmarkup); if (IsSaved) { MessageBox.Show("Saved Sussfully"); } }