private void IssueGRN() { DateTime DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text); ERPConfig clsERPConfig = new ERPConfig(); ERPConfigDetails clsERPConfigDetails = clsERPConfig.Details(); clsERPConfig.CommitAndDispose(); if (clsERPConfigDetails.PostingDateFrom <= DeliveryDate && clsERPConfigDetails.PostingDateTo >= DeliveryDate) { long BranchTransferID = Convert.ToInt64(lblBranchTransferID.Text); string ReceivedBy = txtReceivedBy.Text; BranchTransfer clsBranchTransfer = new BranchTransfer(); clsBranchTransfer.IssueGRN(BranchTransferID, ReceivedBy, DeliveryDate); clsBranchTransfer.CommitAndDispose(); string stParam = "?task=" + Common.Encrypt("list", Session.SessionID) + "&BranchTransferID=" + Common.Encrypt(BranchTransferID.ToString(), Session.SessionID); Response.Redirect("Default.aspx" + stParam); } else { string stScript = "<Script>"; stScript += "window.alert('Sorry you cannot post using the delivery date: " + txtDeliveryDate.Text + ". Please enter an allowable posting date.')"; stScript += "</Script>"; Response.Write(stScript); } }
private Int64 SaveRecord() { BranchTransfer clsBranchTransfer = new BranchTransfer(); clsBranchTransfer.GetConnection(); lblBranchTransferNo.Text = Constants.BRANCH_TRANSFER_CODE + CompanyDetails.BECompanyCode + DateTime.Now.Year.ToString() + clsBranchTransfer.LastTransactionNo(); BranchTransferDetails clsDetails = new BranchTransferDetails(); clsDetails.BranchTransferNo = lblBranchTransferNo.Text; clsDetails.BranchTransferDate = Convert.ToDateTime(lblBranchTransferDate.Text); clsDetails.BranchIDFrom = Convert.ToInt16(cboBranchFrom.SelectedItem.Value); clsDetails.BranchIDTo = Convert.ToInt16(cboBranchTo.SelectedItem.Value); clsDetails.RequiredDeliveryDate = Convert.ToDateTime(txtRequiredDeliveryDate.Text); clsDetails.TransferrerID = Convert.ToInt64(Session["UID"].ToString()); clsDetails.TransferrerName = Session["Name"].ToString(); clsDetails.RequestedBy = txtRequestedBy.Text; clsDetails.Status = BranchTransferStatus.Open; clsDetails.Remarks = txtRemarks.Text; Int64 id = clsBranchTransfer.Insert(clsDetails); clsBranchTransfer.CommitAndDispose(); return(id); }
private bool DeleteItems() { bool boRetValue = false; string stIDs = ""; foreach (DataListItem item in lstItem.Items) { HtmlInputCheckBox chkList = (HtmlInputCheckBox)item.FindControl("chkList"); if (chkList != null) { if (chkList.Checked == true) { stIDs += chkList.Value + ","; boRetValue = true; } } } if (boRetValue) { BranchTransferItem clsBranchTransferItem = new BranchTransferItem(); clsBranchTransferItem.Delete(stIDs.Substring(0, stIDs.Length - 1)); BranchTransfer clsBranchTransfer = new BranchTransfer(clsBranchTransferItem.Connection, clsBranchTransferItem.Transaction); clsBranchTransfer.SynchronizeAmount(Convert.ToInt64(lblBranchTransferID.Text)); BranchTransferDetails clsBranchTransferDetails = clsBranchTransfer.Details(Convert.ToInt64(lblBranchTransferID.Text)); clsBranchTransferItem.CommitAndDispose(); UpdateFooter(clsBranchTransferDetails); } return(boRetValue); }
public ActionResult Edit([Bind(Include = "Id,EmployeeId,FromBranchId,ToBranchId,TransferDate")] BranchTransfer branchTransfer) { if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin") { if (ModelState.IsValid) { int toBranchId = Convert.ToInt32(Request["BranchId"]); branchTransfer.ToBranchId = toBranchId; int fromBranchId = db.Employee.Where(i => i.BranchId == branchTransfer.EmployeeId).Select(i => i.BranchId).FirstOrDefault(); db.Entry(branchTransfer).State = EntityState.Modified; db.SaveChanges(); Employee employee = db.Employee.Find(branchTransfer.EmployeeId); employee.BranchId = toBranchId; db.Entry(employee).State = EntityState.Modified; return(RedirectToAction("Index")); } BranchTransfer BranchTransfer = db.BranchTransfer.Find(branchTransfer.Id); ViewBag.Branch = db.Branch.Where(i => i.Id == branchTransfer.ToBranchId).Select(i => i.Name).FirstOrDefault(); List <Branch> branch = new List <Branch>(); branch = db.Branch.Where(i => i.Status == true).ToList(); ViewBag.BranchId = new SelectList(branch, "Id", "Name"); } else { return(RedirectToAction("Login", "Account")); } return(View(branchTransfer)); }
public ActionResult Create([Bind(Include = "Id,EmployeeId,FromBranchId,ToBranchId,TransferDate")] BranchTransfer branchTransfer) { if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin") { if (ModelState.IsValid) { int fromBranchId = db.Employee.Where(i => i.BranchId == branchTransfer.EmployeeId).Select(x => x.BranchId).FirstOrDefault(); int toBranchId = Convert.ToInt32(Request["ToBranchId"]); branchTransfer.FromBranchId = fromBranchId; branchTransfer.ToBranchId = toBranchId; db.BranchTransfer.Add(branchTransfer); db.SaveChanges(); Employee employee = db.Employee.Find(branchTransfer.EmployeeId); employee.BranchId = toBranchId; db.Entry(employee).State = EntityState.Modified; db.SaveChanges(); TempData["Message"] = "Creation Success!"; return(RedirectToAction("Index")); } List <Branch> branchList = new List <Branch>(); branchList = db.Branch.Where(i => i.Status == true).ToList(); ViewBag.ToBranchId = new SelectList(branchList, "Id", "Name"); List <Employee> employeelist = new List <Employee>(); employeelist = db.Employee.Where(i => i.Status == true).ToList(); ViewBag.EmployeeId = new SelectList(employeelist, "Id", "Name"); return(View(branchTransfer)); } else { return(RedirectToAction("Login", "Account")); } }
// GET: BranchTransfers/Edit/5 public ActionResult Edit(int?id) { if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BranchTransfer branchTransfer = db.BranchTransfer.Find(id); ViewBag.Branch = db.Branch.Where(i => i.Id == branchTransfer.ToBranchId).Select(i => i.Name).FirstOrDefault(); List <Branch> branch = new List <Branch>(); branch = db.Branch.Where(i => i.Status == true).ToList(); ViewBag.BranchId = new SelectList(branch, "Id", "Name"); if (branchTransfer == null) { return(HttpNotFound()); } List <Branch> branchList = new List <Branch>(); branchList = db.Branch.Where(i => i.Status == true).ToList(); ViewBag.BranchId = new SelectList(branchList, "Id", "Name"); return(View(branchTransfer)); } else { return(RedirectToAction("Login", "Account")); } }
private void LoadRecord() { Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["BranchTransferID"], Session.SessionID)); BranchTransfer clsBranchTransfer = new BranchTransfer(); BranchTransferDetails clsDetails = clsBranchTransfer.Details(iID); clsBranchTransfer.CommitAndDispose(); lblBranchTransferID.Text = clsDetails.BranchTransferID.ToString(); lblBranchTransferNo.Text = clsDetails.BranchTransferNo; lblBranchTransferDate.Text = clsDetails.BranchTransferDate.ToString("yyyy-MM-dd HH:mm:ss"); lblRequiredDeliveryDate.Text = clsDetails.RequiredDeliveryDate.ToString("yyyy-MM-dd"); lblBranchCodeFrom.Text = clsDetails.BranchCodeFrom; lblBranchCodeTo.Text = clsDetails.BranchCodeTo; lblBranchTransferRemarks.Text = clsDetails.Remarks; txtBranchTransferDiscountApplied.Text = clsDetails.DiscountApplied.ToString("###0.#0"); cboBranchTransferDiscountType.SelectedIndex = cboBranchTransferDiscountType.Items.IndexOf(cboBranchTransferDiscountType.Items.FindByValue(clsDetails.DiscountType.ToString("d"))); lblBranchTransferDiscount.Text = clsDetails.Discount.ToString("#,##0.#0"); lblBranchTransferVatableAmount.Text = clsDetails.VatableAmount.ToString("#,##0.#0"); txtBranchTransferFreight.Text = clsDetails.Freight.ToString("#,##0.#0"); txtBranchTransferDeposit.Text = clsDetails.Deposit.ToString("#,##0.#0"); lblBranchTransferSubTotal.Text = Convert.ToDecimal(clsDetails.SubTotal - clsDetails.VAT + clsDetails.Freight - clsDetails.Deposit).ToString("#,##0.#0"); lblBranchTransferVAT.Text = clsDetails.VAT.ToString("#,##0.#0"); lblBranchTransferTotal.Text = clsDetails.SubTotal.ToString("#,##0.#0"); }
private void SetDataSource(ReportDocument Report) { Int64 iID = 0; try { if (Request.QueryString["task"].ToString().ToLower() == "reportfromposted" && Request.QueryString["branchtransferid"].ToString() != null) { iID = Convert.ToInt64(Request.QueryString["branchtransferid"].ToString()); } else { iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["branchtransferid"].ToString(), Session.SessionID)); } } catch { iID = Convert.ToInt64(Common.Decrypt(lblReferrer.Text.Substring(lblReferrer.Text.IndexOf("branchtransferid") + 13), Session.SessionID)); } ReportDataset rptds = new ReportDataset(); BranchTransfer clsBranchTransfer = new BranchTransfer(); System.Data.DataTable dt = clsBranchTransfer.ListAsDataTable(iID); BranchTransferItem clsBranchTransferItem = new BranchTransferItem(clsBranchTransfer.Connection, clsBranchTransfer.Transaction); System.Data.DataTable dtitems = clsBranchTransferItem.ListAsDataTable(iID); clsBranchTransfer.CommitAndDispose(); foreach (System.Data.DataRow dr in dt.Rows) { DataRow drNew = rptds.BranchTransfer.NewRow(); foreach (DataColumn dc in rptds.BranchTransfer.Columns) { drNew[dc] = dr[dc.ColumnName]; } rptds.BranchTransfer.Rows.Add(drNew); } foreach (System.Data.DataRow dr in dtitems.Rows) { DataRow drNew = rptds.BranchTransferItems.NewRow(); foreach (DataColumn dc in rptds.BranchTransferItems.Columns) { drNew[dc] = dr[dc.ColumnName]; } rptds.BranchTransferItems.Rows.Add(drNew); } Report.SetDataSource(rptds); SetParameters(Report); }
private void CancelBranchTransfer() { long BranchTransferID = Convert.ToInt64(lblBranchTransferID.Text); string Remarks = txtRemarks.Text; BranchTransfer clsBranchTransfer = new BranchTransfer(); clsBranchTransfer.Cancel(BranchTransferID, DateTime.Now, Remarks, Convert.ToInt64(Session["UID"].ToString())); clsBranchTransfer.CommitAndDispose(); Response.Redirect("Default.aspx?task=" + Common.Encrypt("list", Session.SessionID)); }
public ActionResult DeleteConfirmed(int id) { if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin") { BranchTransfer branchTransfer = db.BranchTransfer.Find(id); db.BranchTransfer.Remove(branchTransfer); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Login", "Account")); } }
private void UpdateDeposit() { BranchTransferDetails clsBranchTransferDetails = new BranchTransferDetails(); clsBranchTransferDetails.BranchTransferID = Convert.ToInt64(lblBranchTransferID.Text); clsBranchTransferDetails.Deposit = Convert.ToDecimal(txtBranchTransferDeposit.Text); BranchTransfer clsBranchTransfer = new BranchTransfer(); clsBranchTransfer.UpdateDeposit(clsBranchTransferDetails.BranchTransferID, clsBranchTransferDetails.Deposit); clsBranchTransfer.SynchronizeAmount(Convert.ToInt64(lblBranchTransferID.Text)); clsBranchTransferDetails = clsBranchTransfer.Details(Convert.ToInt64(lblBranchTransferID.Text)); clsBranchTransfer.CommitAndDispose(); UpdateFooter(clsBranchTransferDetails); }
private void UpdateBranchTransferDiscount() { BranchTransferDetails clsBranchTransferDetails = new BranchTransferDetails(); clsBranchTransferDetails.BranchTransferID = Convert.ToInt64(lblBranchTransferID.Text); clsBranchTransferDetails.DiscountApplied = Convert.ToDecimal(txtBranchTransferDiscountApplied.Text); clsBranchTransferDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboBranchTransferDiscountType.SelectedItem.Value); BranchTransfer clsBranchTransfer = new BranchTransfer(); clsBranchTransfer.UpdateDiscount(clsBranchTransferDetails.BranchTransferID, clsBranchTransferDetails.DiscountApplied, clsBranchTransferDetails.DiscountType); clsBranchTransfer.SynchronizeAmount(Convert.ToInt64(lblBranchTransferID.Text)); clsBranchTransferDetails = clsBranchTransfer.Details(Convert.ToInt64(lblBranchTransferID.Text)); clsBranchTransfer.CommitAndDispose(); UpdateFooter(clsBranchTransferDetails); }
private void LoadRecord() { Int64 iID = Convert.ToInt64(Common.Decrypt(Request.QueryString["BranchTransferID"], Session.SessionID)); BranchTransfer clsBranchTransfer = new BranchTransfer(); BranchTransferDetails clsDetails = clsBranchTransfer.Details(iID); clsBranchTransfer.CommitAndDispose(); lblBranchTransferID.Text = clsDetails.BranchTransferID.ToString(); lblBranchTransferNo.Text = clsDetails.BranchTransferNo; lblBranchTransferDate.Text = clsDetails.BranchTransferDate.ToString("yyyy-MM-dd HH:mm:ss"); txtRequiredDeliveryDate.Text = clsDetails.RequiredDeliveryDate.ToString("yyyy-MM-dd"); cboBranchFrom.SelectedIndex = cboBranchFrom.Items.IndexOf(cboBranchFrom.Items.FindByValue(clsDetails.BranchIDFrom.ToString())); cboBranchTo.SelectedIndex = cboBranchTo.Items.IndexOf(cboBranchTo.Items.FindByValue(clsDetails.BranchIDTo.ToString())); txtRequestedBy.Text = clsDetails.RequestedBy; txtRemarks.Text = clsDetails.Remarks; }
// GET: BranchTransfers/Details/5 public ActionResult Details(int?id) { if (Session["ADMIN"] != null || Session["ADMIN"].ToString() == "admin") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BranchTransfer branchTransfer = db.BranchTransfer.Find(id); if (branchTransfer == null) { return(HttpNotFound()); } return(View(branchTransfer)); } else { return(RedirectToAction("Login", "Account")); } }
private void SaveRecord() { BranchTransferDetails clsDetails = new BranchTransferDetails(); clsDetails.BranchTransferID = long.Parse(lblBranchTransferID.Text); clsDetails.BranchTransferNo = lblBranchTransferNo.Text; clsDetails.BranchTransferDate = Convert.ToDateTime(lblBranchTransferDate.Text); clsDetails.BranchIDFrom = Convert.ToInt16(cboBranchFrom.SelectedItem.Value); clsDetails.BranchIDTo = Convert.ToInt16(cboBranchTo.SelectedItem.Value); clsDetails.RequiredDeliveryDate = Convert.ToDateTime(txtRequiredDeliveryDate.Text); clsDetails.TransferrerID = Convert.ToInt64(Session["UID"].ToString()); clsDetails.TransferrerName = Session["Name"].ToString(); clsDetails.RequestedBy = txtRequestedBy.Text; clsDetails.Status = BranchTransferStatus.Open; clsDetails.Remarks = txtRemarks.Text; BranchTransfer clsBranchTransfer = new BranchTransfer(); clsBranchTransfer.Update(clsDetails); clsBranchTransfer.CommitAndDispose(); }
private void LoadList() { BranchTransfer clsBranchTransfer = new BranchTransfer(); DataClass clsDataClass = new DataClass(); Common Common = new Common(); string SortField = "BranchTransferID"; if (Request.QueryString["sortfield"] != null) { SortField = Common.Decrypt(Request.QueryString["sortfield"].ToString(), Session.SessionID); } SortOption sortoption = SortOption.Ascending; if (Request.QueryString["sortoption"] != null) { sortoption = (SortOption)Enum.Parse(typeof(SortOption), Common.Decrypt(Request.QueryString["sortoption"], Session.SessionID), true); } DateTime dteTransferStartDate = DateTime.MinValue; try { if (txtTransferStartDate.Text != string.Empty) { dteTransferStartDate = Convert.ToDateTime(txtTransferStartDate.Text + " " + txtTransferStartTime.Text); } } catch { } DateTime dteTransferEndDate = DateTime.MinValue; try { if (txtTransferEndDate.Text != string.Empty) { dteTransferEndDate = Convert.ToDateTime(txtTransferEndDate.Text + " " + txtTransferEndTime.Text); } } catch { } DateTime dtePostingStartDate = DateTime.MinValue; try { if (txtPostingStartDate.Text != string.Empty) { dtePostingStartDate = Convert.ToDateTime(txtPostingStartDate.Text + " " + txtPostingStartTime.Text); } } catch { } DateTime dtePostingEndDate = DateTime.MinValue; try { if (txtPostingEndDate.Text != string.Empty) { dtePostingEndDate = Convert.ToDateTime(txtPostingEndDate.Text + " " + txtPostingEndTime.Text); } } catch { } BranchTransferDetails searchKey = new BranchTransferDetails(); searchKey.BranchTransferNo = txtSearch.Text; BranchTransferStatus status = (BranchTransferStatus)Enum.Parse(typeof(BranchTransferStatus), cboStatus.SelectedItem.Value); PageData.DataSource = clsBranchTransfer.ListAsDataTable(0, 0, searchKey, status, dteTransferStartDate, dteTransferEndDate, dtePostingStartDate, dtePostingEndDate, null, null, SortField, sortoption).DefaultView; clsBranchTransfer.CommitAndDispose(); int iPageSize = Convert.ToInt16(Session["PageSize"]); PageData.AllowPaging = true; PageData.PageSize = iPageSize; try { PageData.CurrentPageIndex = Convert.ToInt16(cboCurrentPage.SelectedItem.Value) - 1; lstItem.DataSource = PageData; lstItem.DataBind(); } catch { PageData.CurrentPageIndex = 1; lstItem.DataSource = PageData; lstItem.DataBind(); } cboCurrentPage.Items.Clear(); for (int i = 0; i < PageData.PageCount; i++) { int iValue = i + 1; cboCurrentPage.Items.Add(new ListItem(iValue.ToString(), iValue.ToString())); if (PageData.CurrentPageIndex == i) { cboCurrentPage.Items[i].Selected = true; } else { cboCurrentPage.Items[i].Selected = false; } } lblDataCount.Text = " of " + " " + PageData.PageCount; }
public long Insert(BranchTransferItemDetails Details) { try { string SQL = "INSERT INTO tblBranchTransferItems (" + "BranchTransferID, " + "ProductID, " + "ProductCode, " + "BarCode, " + "Description, " + "ProductUnitID, " + "ProductUnitCode, " + "Quantity, " + "UnitCost, " + "Discount, " + "DiscountApplied, " + "DiscountType, " + "Amount, " + "VAT, " + "VatableAmount, " + "EVAT, " + "EVatableAmount, " + "LocalTax, " + "isVATInclusive, " + "VariationMatrixID, " + "MatrixDescription, " + "ProductGroup, " + "ProductSubGroup, " + "BranchTransferItemStatus, " + "IsVatable, " + "Remarks, " + "SellingPrice," + "SellingVAT," + "SellingEVAT," + "SellingLocalTax," + "OldSellingPrice" + ") VALUES (" + "@BranchTransferID, " + "@ProductID, " + "@ProductCode, " + "@BarCode, " + "@Description, " + "@ProductUnitID, " + "@ProductUnitCode, " + "@Quantity, " + "@UnitCost, " + "@Discount, " + "@DiscountApplied, " + "@DiscountType, " + "@Amount, " + "@VAT, " + "@VatableAmount, " + "@EVAT, " + "@EVatableAmount, " + "@LocalTax, " + "@isVATInclusive, " + "@VariationMatrixID, " + "@MatrixDescription, " + "@ProductGroup, " + "@ProductSubGroup, " + "@BranchTransferItemStatus, " + "@IsVatable, " + "@Remarks, " + "@SellingPrice," + "@SellingVAT," + "@SellingEVAT," + "@SellingLocalTax," + "@OldSellingPrice" + ");"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmBranchTransferID = new MySqlParameter("@BranchTransferID", MySqlDbType.Int64); prmBranchTransferID.Value = Details.BranchTransferID; cmd.Parameters.Add(prmBranchTransferID); MySqlParameter prmProductID = new MySqlParameter("@ProductID", MySqlDbType.Int64); prmProductID.Value = Details.ProductID; cmd.Parameters.Add(prmProductID); MySqlParameter prmProductCode = new MySqlParameter("@ProductCode", MySqlDbType.String); prmProductCode.Value = Details.ProductCode; cmd.Parameters.Add(prmProductCode); MySqlParameter prmBarCode = new MySqlParameter("@BarCode", MySqlDbType.String); prmBarCode.Value = Details.BarCode; cmd.Parameters.Add(prmBarCode); MySqlParameter prmDescription = new MySqlParameter("@Description", MySqlDbType.String); prmDescription.Value = Details.Description; cmd.Parameters.Add(prmDescription); MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID", MySqlDbType.Int16); prmProductUnitID.Value = Details.ProductUnitID; cmd.Parameters.Add(prmProductUnitID); MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode", MySqlDbType.String); prmProductUnitCode.Value = Details.ProductUnitCode; cmd.Parameters.Add(prmProductUnitCode); MySqlParameter prmQuantity = new MySqlParameter("@Quantity", MySqlDbType.Decimal); prmQuantity.Value = Details.Quantity; cmd.Parameters.Add(prmQuantity); MySqlParameter prmUnitCost = new MySqlParameter("@UnitCost", MySqlDbType.Decimal); prmUnitCost.Value = Details.UnitCost; cmd.Parameters.Add(prmUnitCost); MySqlParameter prmDiscount = new MySqlParameter("@Discount", MySqlDbType.Decimal); prmDiscount.Value = Details.Discount; cmd.Parameters.Add(prmDiscount); MySqlParameter prmDiscountApplied = new MySqlParameter("@DiscountApplied", MySqlDbType.Decimal); prmDiscountApplied.Value = Details.DiscountApplied; cmd.Parameters.Add(prmDiscountApplied); MySqlParameter prmDiscountType = new MySqlParameter("@DiscountType", MySqlDbType.Int16); prmDiscountType.Value = (int)Details.DiscountType; cmd.Parameters.Add(prmDiscountType); MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); MySqlParameter prmVAT = new MySqlParameter("@VAT", MySqlDbType.Decimal); prmVAT.Value = Details.VAT; cmd.Parameters.Add(prmVAT); MySqlParameter prmVatableAmount = new MySqlParameter("@VatableAmount", MySqlDbType.Decimal); prmVatableAmount.Value = Details.VatableAmount; cmd.Parameters.Add(prmVatableAmount); MySqlParameter prmEVAT = new MySqlParameter("@EVAT", MySqlDbType.Decimal); prmEVAT.Value = Details.EVAT; cmd.Parameters.Add(prmEVAT); MySqlParameter prmEVatableAmount = new MySqlParameter("@EVatableAmount", MySqlDbType.Decimal); prmEVatableAmount.Value = Details.EVatableAmount; cmd.Parameters.Add(prmEVatableAmount); MySqlParameter prmLocalTax = new MySqlParameter("@LocalTax", MySqlDbType.Decimal); prmLocalTax.Value = Details.LocalTax; cmd.Parameters.Add(prmLocalTax); MySqlParameter prmisVATInclusive = new MySqlParameter("@isVATInclusive", MySqlDbType.Int16); prmisVATInclusive.Value = Convert.ToInt16(Details.isVATInclusive); cmd.Parameters.Add(prmisVATInclusive); MySqlParameter prmVariationMatrixID = new MySqlParameter("@VariationMatrixID", MySqlDbType.Int64); prmVariationMatrixID.Value = Details.VariationMatrixID; cmd.Parameters.Add(prmVariationMatrixID); MySqlParameter prmMatrixDescription = new MySqlParameter("@MatrixDescription", MySqlDbType.String); prmMatrixDescription.Value = Details.MatrixDescription; cmd.Parameters.Add(prmMatrixDescription); MySqlParameter prmProductGroup = new MySqlParameter("@ProductGroup", MySqlDbType.String); prmProductGroup.Value = Details.ProductGroup; cmd.Parameters.Add(prmProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@BranchTransferItemStatus", Details.BranchTransferItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@SellingPrice", Details.SellingPrice); cmd.Parameters.AddWithValue("@SellingVAT", Details.SellingVAT); cmd.Parameters.AddWithValue("@SellingEVAT", Details.SellingEVAT); cmd.Parameters.AddWithValue("@SellingLocalTax", Details.SellingLocalTax); cmd.Parameters.AddWithValue("@OldSellingPrice", Details.OldSellingPrice); base.ExecuteNonQuery(cmd); SQL = "SELECT LAST_INSERT_ID();"; cmd.Parameters.Clear(); cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); Int64 iID = 0; foreach (System.Data.DataRow dr in dt.Rows) { iID = Int64.Parse(dr[0].ToString()); } BranchTransfer clsBranchTransfer = new BranchTransfer(base.Connection, base.Transaction); clsBranchTransfer.SynchronizeAmount(Details.BranchTransferID); return(iID); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void Update(BranchTransferItemDetails Details) { try { string SQL = "UPDATE tblBranchTransferItems SET " + "BranchTransferID = @BranchTransferID, "+ "ProductID = @ProductID, "+ "ProductCode = @ProductCode, "+ "BarCode = @BarCode, "+ "Description = @Description, "+ "ProductUnitID = @ProductUnitID, "+ "ProductUnitCode = @ProductUnitCode, "+ "Quantity = @Quantity, "+ "UnitCost = @UnitCost, "+ "Discount = @Discount, "+ "DiscountApplied = @DiscountApplied, "+ "DiscountType = @DiscountType, "+ "Amount = @Amount, "+ "VAT = @VAT, "+ "VatableAmount = @VatableAmount, "+ "EVAT = @EVAT, "+ "EVatableAmount = @EVatableAmount, "+ "LocalTax = @LocalTax, "+ "isVATInclusive = @isVATInclusive, "+ "VariationMatrixID = @VariationMatrixID, "+ "MatrixDescription = @MatrixDescription, "+ "ProductGroup = @ProductGroup, "+ "ProductSubGroup = @ProductSubGroup, "+ "BranchTransferItemStatus = @BranchTransferItemStatus, "+ "IsVatable = @IsVatable, "+ "Remarks = @Remarks, "+ "SellingPrice = @SellingPrice, "+ "SellingVAT = @SellingVAT, "+ "SellingEVAT = @SellingEVAT, "+ "SellingLocalTax = @SellingLocalTax, "+ "OldSellingPrice = @OldSellingPrice "+ "WHERE BranchTransferItemID = @BranchTransferItemID;"; MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = SQL; MySqlParameter prmBranchTransferID = new MySqlParameter("@BranchTransferID", MySqlDbType.Int64); prmBranchTransferID.Value = Details.BranchTransferID; cmd.Parameters.Add(prmBranchTransferID); MySqlParameter prmProductID = new MySqlParameter("@ProductID", MySqlDbType.Int64); prmProductID.Value = Details.ProductID; cmd.Parameters.Add(prmProductID); MySqlParameter prmProductCode = new MySqlParameter("@ProductCode", MySqlDbType.String); prmProductCode.Value = Details.ProductCode; cmd.Parameters.Add(prmProductCode); MySqlParameter prmBarCode = new MySqlParameter("@BarCode", MySqlDbType.String); prmBarCode.Value = Details.BarCode; cmd.Parameters.Add(prmBarCode); MySqlParameter prmDescription = new MySqlParameter("@Description", MySqlDbType.String); prmDescription.Value = Details.Description; cmd.Parameters.Add(prmDescription); MySqlParameter prmProductUnitID = new MySqlParameter("@ProductUnitID", MySqlDbType.Int16); prmProductUnitID.Value = Details.ProductUnitID; cmd.Parameters.Add(prmProductUnitID); MySqlParameter prmProductUnitCode = new MySqlParameter("@ProductUnitCode", MySqlDbType.String); prmProductUnitCode.Value = Details.ProductUnitCode; cmd.Parameters.Add(prmProductUnitCode); MySqlParameter prmQuantity = new MySqlParameter("@Quantity", MySqlDbType.Decimal); prmQuantity.Value = Details.Quantity; cmd.Parameters.Add(prmQuantity); MySqlParameter prmUnitCost = new MySqlParameter("@UnitCost", MySqlDbType.Decimal); prmUnitCost.Value = Details.UnitCost; cmd.Parameters.Add(prmUnitCost); MySqlParameter prmDiscount = new MySqlParameter("@Discount", MySqlDbType.Decimal); prmDiscount.Value = Details.Discount; cmd.Parameters.Add(prmDiscount); MySqlParameter prmDiscountApplied = new MySqlParameter("@DiscountApplied", MySqlDbType.Decimal); prmDiscountApplied.Value = Details.DiscountApplied; cmd.Parameters.Add(prmDiscountApplied); MySqlParameter prmDiscountType = new MySqlParameter("@DiscountType", MySqlDbType.Int16); prmDiscountType.Value = (int)Details.DiscountType; cmd.Parameters.Add(prmDiscountType); MySqlParameter prmAmount = new MySqlParameter("@Amount", MySqlDbType.Decimal); prmAmount.Value = Details.Amount; cmd.Parameters.Add(prmAmount); MySqlParameter prmVAT = new MySqlParameter("@VAT", MySqlDbType.Decimal); prmVAT.Value = Details.VAT; cmd.Parameters.Add(prmVAT); MySqlParameter prmVatableAmount = new MySqlParameter("@VatableAmount", MySqlDbType.Decimal); prmVatableAmount.Value = Details.VatableAmount; cmd.Parameters.Add(prmVatableAmount); MySqlParameter prmEVAT = new MySqlParameter("@EVAT", MySqlDbType.Decimal); prmEVAT.Value = Details.EVAT; cmd.Parameters.Add(prmEVAT); MySqlParameter prmEVatableAmount = new MySqlParameter("@EVatableAmount", MySqlDbType.Decimal); prmEVatableAmount.Value = Details.EVatableAmount; cmd.Parameters.Add(prmEVatableAmount); MySqlParameter prmLocalTax = new MySqlParameter("@LocalTax", MySqlDbType.Decimal); prmLocalTax.Value = Details.LocalTax; cmd.Parameters.Add(prmLocalTax); MySqlParameter prmisVATInclusive = new MySqlParameter("@isVATInclusive", MySqlDbType.Int16); prmisVATInclusive.Value = Convert.ToInt16(Details.isVATInclusive); cmd.Parameters.Add(prmisVATInclusive); MySqlParameter prmVariationMatrixID = new MySqlParameter("@VariationMatrixID", MySqlDbType.Int64); prmVariationMatrixID.Value = Details.VariationMatrixID; cmd.Parameters.Add(prmVariationMatrixID); MySqlParameter prmMatrixDescription = new MySqlParameter("@MatrixDescription", MySqlDbType.String); prmMatrixDescription.Value = Details.MatrixDescription; cmd.Parameters.Add(prmMatrixDescription); MySqlParameter prmProductGroup = new MySqlParameter("@ProductGroup", MySqlDbType.String); prmProductGroup.Value = Details.ProductGroup; cmd.Parameters.Add(prmProductGroup); cmd.Parameters.AddWithValue("@ProductSubGroup", Details.ProductSubGroup); cmd.Parameters.AddWithValue("@BranchTransferItemStatus", Details.BranchTransferItemStatus.ToString("d")); cmd.Parameters.AddWithValue("@IsVatable", Convert.ToInt16(Details.IsVatable)); cmd.Parameters.AddWithValue("@Remarks", Details.Remarks); cmd.Parameters.AddWithValue("@SellingPrice", Details.SellingPrice); cmd.Parameters.AddWithValue("@SellingVAT", Details.SellingVAT); cmd.Parameters.AddWithValue("@SellingEVAT", Details.SellingEVAT); cmd.Parameters.AddWithValue("@SellingLocalTax", Details.SellingLocalTax); cmd.Parameters.AddWithValue("@OldSellingPrice", Details.OldSellingPrice); cmd.Parameters.AddWithValue("@BranchTransferItemID", Details.BranchTransferItemID); base.ExecuteNonQuery(cmd); BranchTransfer clsBranchTransfer = new BranchTransfer(base.Connection, base.Transaction); clsBranchTransfer.SynchronizeAmount(Details.BranchTransferID); } catch (Exception ex) { throw base.ThrowException(ex); } }
private void SaveRecord() { BranchTransferItemDetails clsDetails = new BranchTransferItemDetails(); Products clsProducts = new Products(); ProductDetails clsProductDetails = clsProducts.Details1(Constants.BRANCH_ID_MAIN, Convert.ToInt64(cboProductCode.SelectedItem.Value)); Terminal clsTerminal = new Terminal(clsProducts.Connection, clsProducts.Transaction); TerminalDetails clsTerminalDetails = clsTerminal.Details(Int32.Parse(Session["BranchID"].ToString()), Session["TerminalNo"].ToString()); clsProducts.CommitAndDispose(); clsDetails.BranchTransferID = Convert.ToInt64(lblBranchTransferID.Text); clsDetails.ProductID = Convert.ToInt64(cboProductCode.SelectedItem.Value); clsDetails.ProductCode = clsProductDetails.ProductCode; clsDetails.BarCode = clsProductDetails.BarCode; clsDetails.Description = clsProductDetails.ProductDesc; clsDetails.ProductUnitID = Convert.ToInt32(cboProductUnit.SelectedItem.Value); clsDetails.ProductUnitCode = cboProductUnit.SelectedItem.Text; clsDetails.Quantity = Convert.ToDecimal(txtQuantity.Text); clsDetails.UnitCost = Convert.ToDecimal(txtPrice.Text); clsDetails.Discount = getItemTotalDiscount(); clsDetails.DiscountApplied = Convert.ToDecimal(txtDiscount.Text); if (clsDetails.DiscountApplied == 0) { if (chkInPercent.Checked == true) { clsDetails.DiscountType = DiscountTypes.Percentage; } else { clsDetails.DiscountType = DiscountTypes.FixedValue; } } else { clsDetails.DiscountType = DiscountTypes.NotApplicable; } clsDetails.IsVatable = chkIsTaxable.Checked; clsDetails.Amount = ComputeItemAmount(); if (clsDetails.IsVatable) { clsDetails.VatableAmount = clsDetails.Amount; clsDetails.EVatableAmount = clsDetails.Amount; clsDetails.LocalTax = clsDetails.Amount; if (clsTerminalDetails.IsVATInclusive == false) { if (clsDetails.VatableAmount < clsDetails.Discount) { clsDetails.VatableAmount = 0; } if (clsDetails.EVatableAmount < clsDetails.Discount) { clsDetails.EVatableAmount = 0; } if (clsDetails.LocalTax < clsDetails.Discount) { clsDetails.LocalTax = 0; } } else { if (clsDetails.VatableAmount >= clsDetails.Discount) { clsDetails.VatableAmount = (clsDetails.VatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); } else { clsDetails.VatableAmount = 0; } if (clsDetails.EVatableAmount >= clsDetails.Discount) { clsDetails.EVatableAmount = (clsDetails.EVatableAmount) / (1 + (clsTerminalDetails.VAT / 100)); } else { clsDetails.EVatableAmount = 0; } if (clsDetails.LocalTax >= clsDetails.Discount) { clsDetails.LocalTax = (clsDetails.LocalTax) / (1 + (clsTerminalDetails.LocalTax / 100)); } else { clsDetails.LocalTax = 0; } } clsDetails.VAT = clsDetails.VatableAmount * (clsTerminalDetails.VAT / 100); clsDetails.EVAT = clsDetails.EVatableAmount * (clsTerminalDetails.EVAT / 100); clsDetails.LocalTax = clsDetails.LocalTax * (clsTerminalDetails.LocalTax / 100); } else { clsDetails.VAT = 0; clsDetails.VatableAmount = 0; clsDetails.EVAT = 0; clsDetails.EVatableAmount = 0; clsDetails.LocalTax = 0; } clsDetails.isVATInclusive = clsTerminalDetails.IsVATInclusive; clsDetails.VariationMatrixID = Convert.ToInt64(cboVariation.SelectedItem.Value); if (clsDetails.VariationMatrixID != 0) { clsDetails.MatrixDescription = cboVariation.SelectedItem.Text; } clsDetails.ProductGroup = clsProductDetails.ProductGroupCode; clsDetails.ProductSubGroup = clsProductDetails.ProductSubGroupCode; clsDetails.Remarks = txtRemarks.Text; clsDetails.SellingPrice = decimal.Parse(txtSellingPrice.Text); clsDetails.SellingVAT = decimal.Parse(txtVAT.Text); clsDetails.SellingEVAT = decimal.Parse(txtEVAT.Text); clsDetails.SellingLocalTax = decimal.Parse(txtLocalTax.Text); clsDetails.OldSellingPrice = decimal.Parse(txtOldSellingPrice.Text); BranchTransferItem clsBranchTransferItem = new BranchTransferItem(); if (lblBranchTransferItemID.Text != "0") { clsDetails.BranchTransferItemID = Convert.ToInt64(lblBranchTransferItemID.Text); clsBranchTransferItem.Update(clsDetails); } else { clsBranchTransferItem.Insert(clsDetails); } BranchTransferDetails clsBranchTransferDetails = new BranchTransferDetails(); clsBranchTransferDetails.BranchTransferID = clsDetails.BranchTransferID; clsBranchTransferDetails.DiscountApplied = Convert.ToDecimal(txtBranchTransferDiscountApplied.Text); clsBranchTransferDetails.DiscountType = (DiscountTypes)Enum.Parse(typeof(DiscountTypes), cboBranchTransferDiscountType.SelectedItem.Value); BranchTransfer clsBranchTransfer = new BranchTransfer(clsBranchTransferItem.Connection, clsBranchTransferItem.Transaction); clsBranchTransfer.UpdateDiscount(clsDetails.BranchTransferID, clsBranchTransferDetails.DiscountApplied, clsBranchTransferDetails.DiscountType); clsBranchTransferDetails = clsBranchTransfer.Details(clsDetails.BranchTransferID); clsBranchTransferItem.CommitAndDispose(); UpdateFooter(clsBranchTransferDetails); }