private void dgv_Bills_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) { int billID = int.Parse(dgv_Bills.SelectedRows[0].Cells[0].Value.ToString()); supplierBill = context.SupplierBills.FirstOrDefault(b => b.ID == billID); //label3.Text = supplierBill.suppliers.Name; dtp_GBillDate.Value = supplierBill.BillDate; numTotalCost.Value = 0; numTotalCost.Value = Convert.ToDecimal(supplierBill.BillValue); ///sales order payment supplierBillPayment = context.supplierBillPayment.FirstOrDefault(b => b.SupplierBill_Id == billID); numericPaiedCost.Value = 0; numericPaiedCost.Value = Convert.ToDecimal(supplierBillPayment.Paied); numResCost.Value = 0; numResCost.Value = Convert.ToDecimal(supplierBillPayment.Rest); details = context.SuppliersBillDetails.Where(b => b.SupplierBill_Id == billID).ToList(); dgv_SuplierBill.Rows.Clear(); for (var item = 0; item < details.Count; item++) { int pID = details[item].products_Id; var product = context.products.FirstOrDefault(p => p.ID == pID); string pName = product.ProductName; double quantity = product.quantityPerProducts; double price = product.Price_customer; double discount = product.Discount; // error we have to add discount column to generalBillDetail table dgv_SuplierBill.Rows.Add(discount, price, quantity, pName, pID); } }
public SupplierBill OrderIngredientsFromSupplier(int supplierId, int ingredientSupplierId, int amount) { var supplierBill = new SupplierBill(); var ingredientSupplier = _ingredientSupplierRepository.GetIngredientSupplier(ingredientSupplierId); if (ingredientSupplier == null) { throw new ArgumentException("Invalid ingredientSupplierId."); } if (ingredientSupplier.TotalAmount < amount) { throw new ArgumentException("The amount is too high."); } supplierBill.TotalPrice = amount * ingredientSupplier.Price; supplierBill.IngredientId = ingredientSupplier.IngredientId; supplierBill.Amount = amount; ingredientSupplier.TotalAmount = ingredientSupplier.TotalAmount - amount; _ingredientSupplierRepository.UpdateIngredientSupplier(ingredientSupplier); return(supplierBill); }
/// <summary> /// 根据ID获取数据模型 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public string Get(string id) { SupplierBill item = m_BLL.GetById(id); SupplierBill info = new SupplierBill(); info.Id = item.Id; info.PayName = item.PayName; info.BillName = item.BillName; info.TaxRegistryNumber = item.TaxRegistryNumber; info.SupplierId = item.SupplierId; return(Newtonsoft.Json.JsonConvert.SerializeObject(info)); }
private void supplierDailyReportToolStripMenuItem_Click(object sender, EventArgs e) { SupplierBill _form = new SupplierBill(); //this.IsMdiContainer = true; //_form.TopLevel = false; //panel2.Controls.Add(_form); //_form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //panel2.Height = _form.Height; //panel2.Width = _form.Width; //_form.Dock = DockStyle.Fill; _form.ShowDialog(); }
private void BillItems_Load(object sender, EventArgs e) { labelControl5.Text = ucDisplayBills.SetValueForText1; //SupplierBill x = context.SupplierBills.Where(d => d.billID == int.Parse(ucDisplayBills.SetValueForText1)).FirstOrDefault(); SupplierBill xc = context.SupplierBills.Find(z); labelControl6.Text = (xc.billDate.ToString()).Substring(0, 10); labelControl11.Text = xc.Supplier.supplierName; labelControl12.Text = xc.Supplier.supplierAddress; labelControl13.Text = xc.Supplier.supplierPhoneNumber; supplierBillItemBindingSource.DataSource = context.SupplierBillItems.Where(v => v.billID == z).ToList(); itemBindingSource.DataSource = context.Items.ToList(); }
/// <summary> /// 创建一个供应商开票 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个供应商开票</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, SupplierBill entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
public void GetSupplierDetails() { DataSet mDSet = new DataSet(); SupplierBill sbillm = new SupplierBill(); sbillm.Flag = "All"; sbillm.SBillID = 0; sbillm.InvoiceNo = 0; //sbillm.FromDate = ""; //sbillm.ToDate = ""; mDSet = sbillm.GetSupplierDetails(); gvSupplierBill.DataSource = mDSet.Tables[0]; gvSupplierBill.DataBind(); }
/// <summary> /// 创建 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] SupplierBill entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { entity.Id = Common.Result.GetNewId(); entity.CreateUserID = LoginInfo.UserID; entity.CreateTime = DateTime.Now; entity.CreateUserName = LoginInfo.RealName; entity.Status = "启用"; string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",供应商银行账户信息的Id为" + entity.Id, "供应商银行账户" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; return(result); //提示创建成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",供应商银行账户的信息," + returnValue, "供应商银行账户" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
/// <summary> /// 修改 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Put([FromBody] SupplierBill entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { SupplierBill model = m_BLL.GetById(entity.Id); model.PayName = entity.PayName; model.BillName = entity.BillName; model.TaxRegistryNumber = entity.TaxRegistryNumber; string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, model)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",供应商财务信息的Id为" + entity.Id, "供应商财务" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",供应商财务信息的Id为" + entity.Id + "," + returnValue, "供应商财务" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
/// <summary> /// 停用 /// </summary> /// <param name="id"></param> /// <returns></returns> public Common.ClientResult.Result Stop(string id) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (ModelState.IsValid) { //数据校验 SupplierBill item = m_BLL.GetById(id); item.Status = "停用";//停用 string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, item)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",供应商财务信息的Id为" + id, "供应商财务信息_停用" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",供应商财务信息的Id为" + id + "," + returnValue, "供应商财务信息_停用" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
//获得开票信息 private List <SupplierBill> GetBillList(string bill) { List <SupplierBill> list = new List <SupplierBill>(); if (!string.IsNullOrEmpty(bill)) { var jsonData = Newtonsoft.Json.JsonConvert.DeserializeObject <List <SupplierBill> >(bill); for (int i = 0; i < jsonData.Count; i++) { SupplierBill model = new SupplierBill(); model.PayName = jsonData[i].PayName; model.BillName = jsonData[i].BillName; model.TaxRegistryNumber = jsonData[i].TaxRegistryNumber; model.CreateTime = DateTime.Now; model.CreateUserID = LoginInfo.UserID; model.CreateUserName = LoginInfo.RealName; model.Status = Common.Status.启用.ToString(); list.Add(model); } } return(list); }
public void BindSupplierGrid() { if (SBillID != 0) { divSuppDetails.Attributes["class"] = "show"; DataTable mEditDTable = new DataTable(); DataTable mSuppDTable = new DataTable(); SupplierBill sbillm = new SupplierBill(); // Summary sbillm.Flag = "Edit"; sbillm.SBillID = SBillID; mEditDTable = sbillm.GetSupplierDetails().Tables[0]; lblSBillID.Text = mEditDTable.Rows[0]["SBillID"].ToString(); lblSupplierCode.Text = mEditDTable.Rows[0]["SupplierCode"].ToString(); txtSupplierName.Text = mEditDTable.Rows[0]["SupplierName"].ToString(); lblPurchaseCode.Text = mEditDTable.Rows[0]["PurchaseCode"].ToString(); txtPurchaseName.Text = mEditDTable.Rows[0]["PurchaseName"].ToString(); txtInvoiceNo.Text = mEditDTable.Rows[0]["InvoiceNo"].ToString(); txtInvoiceDate.Text = mEditDTable.Rows[0]["InvoiceDate"].ToString(); BindGSTPerDropDown(lblSupplierCode.Text); ddlGSTPer.SelectedValue = mEditDTable.Rows[0]["GSTPer"].ToString(); // Details sbillm.Flag = "Details"; sbillm.SBillID = SBillID; mSuppDTable = sbillm.GetSupplierDetails().Tables[0]; Session["tempdata"] = mSuppDTable; } }
public ActionResult Manage([Bind(Include = "SBillID,SupplierID,SiteID,Tdate")] SupplierBill supplierBill) { supplierBill.TDSperc = (decimal)db.FirstOrDefault <Config>("Select TDSperc from Config").TDSperc; return(base.BaseSave <SupplierBill>(supplierBill, supplierBill.SBillID > 0)); }
protected void btn_Save_Click(object sender, EventArgs e) { if (Session["UserName"] != null) { int MsgID = 0; string Msg = ""; int SBillID = 0; if (gvSupplierBill.Rows.Count > 0) { SupplierBill supbillm = new SupplierBill(); DataSet mDSet = new DataSet(); supbillm.SBillID = Convert.ToInt32(lblSBillID.Text.Trim()); supbillm.SupplierCode = lblSupplierCode.Text.Trim().ToString(); supbillm.SupplierName = txtSupplierName.Text.Trim().ToString(); supbillm.PurchaseCode = lblPurchaseCode.Text.Trim().ToString(); supbillm.PurchaseName = txtPurchaseName.Text.Trim().ToString(); supbillm.InvoiceNo = Convert.ToInt32(txtInvoiceNo.Text.Trim()); supbillm.InvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text.Trim()); supbillm.GSTPer = Convert.ToInt32(ddlGSTPer.SelectedValue.ToString()); supbillm.IsActive = Convert.ToBoolean(true); supbillm.CreatedBy = Session["UserName"].ToString(); supbillm.FY = Convert.ToInt32(strFY); supbillm.SBillDT = SaveSupplierDetails(); mDSet = supbillm.SaveSupplierBill(); if (mDSet.Tables[0].Rows.Count > 0) { MsgID = Convert.ToInt32(mDSet.Tables[0].Rows[0]["MsgID"].ToString()); Msg = (mDSet.Tables[0].Rows[0]["Msg"].ToString()); if (MsgID == 0) { message(Msg); } else { SBillID = Convert.ToInt32(mDSet.Tables[0].Rows[0]["ID"].ToString()); message(Msg + " \\r\\n Bill ID:" + SBillID); ResetSupplierBillFields(); Session["tempdata"] = null; gvSupplierBill.DataBind(); } } if (Request.QueryString["SBillID"] == null) { message("Saved Successfully !!!! \\r\\n Bill ID:" + SBillID); ResetSupplierBillFields(); Session["tempdata"] = null; gvSupplierBill.DataBind(); } else { message("Updated Successfully !!!! \\r\\n Bill ID:" + SBillID); ResetSupplierBillFields(); Session["tempdata"] = null; Response.Redirect("SupplierBill_View.aspx"); } } else { message("Enter Purchase Details"); } } }
public string SaveSupplierDetails() { try { XmlDocument doc = new XmlDocument(); XmlNode inode = doc.CreateElement("f"); XmlNode fnode = doc.CreateElement("r"); SupplierBill suppbilld = new SupplierBill(); foreach (GridViewRow gvrow in gvSupplierBill.Rows) { XmlNode element = doc.CreateElement("i"); int _SBillDID = Convert.ToInt32(((Label)gvrow.FindControl("lblSBillDID")).Text); string _AccountCode = ((Label)gvrow.FindControl("lblAccountCode")).Text.ToString(); string _AccountName = ((Label)gvrow.FindControl("lblAccountName")).Text.ToString(); int _Quantity = Convert.ToInt32(((Label)gvrow.FindControl("lblQuantity")).Text); decimal _Amount = Convert.ToDecimal(((Label)gvrow.FindControl("lblAmount")).Text); string _Remark = ((Label)gvrow.FindControl("lblRemark")).Text; inode = doc.CreateElement("pmdid"); inode.InnerText = _SBillDID.ToString(); element.AppendChild(inode); inode = doc.CreateElement("accode"); inode.InnerText = _AccountCode.ToString(); element.AppendChild(inode); inode = doc.CreateElement("acname"); inode.InnerText = _AccountName.ToString(); element.AppendChild(inode); inode = doc.CreateElement("qty"); inode.InnerText = _Quantity.ToString(); element.AppendChild(inode); inode = doc.CreateElement("rate"); inode.InnerText = _Amount.ToString(); element.AppendChild(inode); inode = doc.CreateElement("per"); inode.InnerText = ddlGSTPer.SelectedItem.Text.ToString(); element.AppendChild(inode); decimal amt = _Amount + (_Amount * Convert.ToDecimal(ddlGSTPer.SelectedItem.Text)) / 100; inode = doc.CreateElement("amt"); inode.InnerText = amt.ToString(); element.AppendChild(inode); inode = doc.CreateElement("remark"); inode.InnerText = _Remark.ToString(); element.AppendChild(inode); inode = doc.CreateElement("crby"); inode.InnerText = Session["UserName"].ToString(); element.AppendChild(inode); fnode.AppendChild(element); } return(xmlstr = fnode.OuterXml.ToString()); } catch (Exception ex) { throw ex; } }