public static void Purchase(PurchaseProvider provider, string sku, Callback callback) { PurchaseProvider = provider; purchaseCallback.Setup(callback); #if UNITY_EDITOR provider = PurchaseProvider.Null; #endif switch (provider) { case PurchaseProvider.Market: if (MarketProxy.Supported) { Online.Purchase.Start(Online.Purchase.Provider.Market, () => MarketProxy.Purchase(sku)); } else { Application.OpenURL(StoreUrl); callback(false, "Bazaar Not Supported!"); } break; case PurchaseProvider.Gateway: callback(false, "faketoken"); break; #if UNITY_EDITOR default: callback(true, "faketoken"); break; #endif } }
// DELETE: api/Configuration/5 public HttpResponseMessage Delete(int id) { var provider = new PurchaseProvider(DbInfo); var deleted = provider.DeletePurchase(id); return(Request.CreateResponse(HttpStatusCode.OK, deleted)); }
/// <summary> /// 绑定Staff信息的数据源 /// </summary> private void BindSource(Purchase purchase, int start) { DataTable table; PurchaseProvider provider = new PurchaseProvider(); table = provider.SelectRec(purchase, start, this.ListPager1.PageSize); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind(); for (int i = 0; i < this.GridView1.Rows.Count; i++) { if (this.GridView1.Rows[i].Cells[3].Text.ToString() == " ") { this.GridView1.Rows[i].Cells[7].Enabled = false; this.GridView1.Rows[i].Cells[8].Enabled = false; } else if (Convert.ToInt32(this.GridView1.Rows[i].Cells[3].Text.ToString()) == 0) { this.GridView1.Rows[i].Cells[7].Enabled = false; this.GridView1.Rows[i].Cells[8].Enabled = false; } } }
protected void btn_Result_Click(object sender, EventArgs e) { Purchase purchase = new Purchase(); if (user_manage == 0) { purchase.Staffinfo_Id = staffinfo_id; } purchase.Purchase_Id = 0; purchase.Year_Month = 0; if (this.txt_Position.Text != "") { purchase.Purchase_Id = Convert.ToInt32(this.txt_Position.Text); } if (this.txt_Yearmonth.Text != "") { purchase.Year_Month = Convert.ToInt32(this.txt_Yearmonth.Text); } if (this.txt_Name.Text != "") { StaffProvider provider1 = new StaffProvider(); purchase.Staffinfo_Id = provider1.GetStaffinfoId(this.txt_Name.Text.ToString()); } PurchaseProvider provider = new PurchaseProvider(); this.ListPager1.RecordCount = provider.GetSize(); this.BindSource(purchase, 0); this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange); }
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int rowIndex = e.RowIndex; Purchase purchase = new Purchase(); purchase.Purchase_Id = Convert.ToInt32(this.GridView1.DataKeys[rowIndex]["purchase_id"]); PurchaseProvider provider = new PurchaseProvider(); if (provider.Delete(purchase)) { this.Alert("删除成功!!!"); if (user_manage == 0) { purchase.Staffinfo_Id = staffinfo_id; } purchase.Purchase_Id = 0; purchase.Year_Month = 0; if (this.txt_Position.Text != "") { purchase.Purchase_Id = Convert.ToInt32(this.txt_Position.Text); } if (this.txt_Yearmonth.Text != "") { purchase.Year_Month = Convert.ToInt32(this.txt_Yearmonth.Text); } this.ListPager1.RecordCount = this.ListPager1.RecordCount - 1; this.BindSource(purchase); } }
public HttpResponseMessage Get(string id) { var certification = new PurchaseProvider(DbInfo).GetPurchase(int.Parse(id)); var exists = certification != null; var status = exists ? HttpStatusCode.OK : HttpStatusCode.NotFound; return(Request.CreateResponse(status, certification)); }
/// <summary> /// 绑定Staff信息的数据源 /// </summary> private void BindSource(int staffinfo_id, int supplier_id) { DataTable table; PurchaseProvider provider = new PurchaseProvider(); table = provider.GetDetails(staffinfo_id, supplier_id); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind(); }
public HttpResponseMessage GetReports(string response_id) { try { var reports = new PurchaseProvider(DbInfo).GetReports(response_id); return(Request.CreateResponse(HttpStatusCode.OK, reports)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, ex.Message)); } }
public HttpResponseMessage GetPurchase(string id) { try { var purchases = new PurchaseProvider(DbInfo).GetPurchases(int.Parse(id)); return(Request.CreateResponse(HttpStatusCode.OK, purchases)); } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.StackTrace)); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PurchaseProvider provider = new PurchaseProvider(); this.ListPager1.RecordCount = provider.GetSize(); this.BindSource(0, "", 0); } this.account.Text = Session["LOGINED"].ToString(); this.datetime.Text = this.BindDayWeek(); this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange); }
// POST: api/Inspection public HttpResponseMessage Post(Purchase purchase) { try { var provider = new PurchaseProvider(DbInfo); var isSaved = provider.Save(purchase); return(Request.CreateResponse(HttpStatusCode.OK, isSaved)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
/// <summary> /// 绑定Users信息的数据源 /// </summary> private void BindSource(int start, string goodId, int yearmonth) { Purchase purchase = new Purchase(); purchase.Good_Id = goodId; purchase.Year_Month = yearmonth; PurchaseProvider provider = new PurchaseProvider(); DataTable table = provider.Select(purchase, start, this.ListPager1.PageSize); this.GridView1.DataSource = table.DefaultView; this.GridView1.DataBind(); }
public static void QueryPurchases(PurchaseProvider provider, Callback callback) { PurchaseProvider = provider; queryCallback.Setup(callback); switch (PurchaseProvider) { case PurchaseProvider.Market: MarketProxy.QueryPurchases(); break; case PurchaseProvider.Gateway: break; } }
public async void VatRateInvalidValidation(decimal vatRate) { // Arrange var serviceProvider = ServiceProvider(); var purchaseProvider = new PurchaseProvider(null, serviceProvider.GetService <IGrossCalculator>() , serviceProvider.GetService <IVatCalculator>(), serviceProvider.GetService <INetCalculator>()); // Act var purchase = await purchaseProvider.GetPurchaseVatAsync( new Purchase { GrossAmount = 120, NetAmount = null, VatAmount = null, VatRate = vatRate }); // Assert Assert.False(purchase.IsSuccess); Assert.Null(purchase.Purchase); Assert.NotNull(purchase.ErrorMessage); }
private void BindText() { Purchase purchase = new Purchase(); purchase.Purchase_Id = Convert.ToInt32(id); PurchaseProvider provider = new PurchaseProvider(); DataTable table = new DataTable(); table = provider.Select(purchase); this.ddl_GoodId.SelectedIndex = this.ddl_GoodId.Items.IndexOf(this.ddl_GoodId.Items.FindByValue(table.Rows[0]["good_id"].ToString())); this.txt_price.Text = table.Rows[0]["purchase_price"].ToString(); this.txt_num.Text = table.Rows[0]["purchase_num"].ToString(); this.txt_datetime.Text = table.Rows[0]["purchase_datetime"].ToString();//DateTime.Now.ToString();//table.Rows[0]["purchase_datetime"].ToString(); this.ddl_supplierid.SelectedIndex = this.ddl_supplierid.Items.IndexOf(this.ddl_supplierid.Items.FindByValue(table.Rows[0]["supplier_id"].ToString())); this.txt_goodname.Text = table.Rows[0]["good_name"].ToString(); }
public async void CalculateAmountFromGross(decimal vatRate, decimal grossAmount, decimal netAmount, decimal vatAmount) { // Arrange var serviceProvider = ServiceProvider(); var purchaseProvider = new PurchaseProvider(null, serviceProvider.GetService <IGrossCalculator>() , serviceProvider.GetService <IVatCalculator>(), serviceProvider.GetService <INetCalculator>()); // Act var purchase = await purchaseProvider.GetPurchaseVatAsync( new Purchase { GrossAmount = grossAmount, NetAmount = null, VatAmount = null, VatRate = vatRate }); // Assert Assert.True(purchase.IsSuccess); Assert.NotNull(purchase.Purchase); Assert.Null(purchase.ErrorMessage); Assert.Equal(purchase.Purchase.NetAmount, netAmount); Assert.Equal(purchase.Purchase.VatAmount, vatAmount); }
protected void Page_Load(object sender, EventArgs e) { if (user_id == 0) { user_id = Convert.ToInt32(Session["USERID"].ToString()); } if (user_manage == 0) { user_manage = Convert.ToInt32(Session["USERMANAGE"].ToString()); } if (staffinfo_id == 0) { StaffProvider provider = new StaffProvider(); staffinfo_id = provider.GetStaffinfoId(user_id); } if (!IsPostBack) { PurchaseProvider provider = new PurchaseProvider(); Purchase purchase = new Purchase(); this.GridView1.DataKeyNames = new string[] { "purchase_id", "staffinfo_id", "supplier_id" }; if (user_manage == 0) { purchase.Staffinfo_Id = staffinfo_id; this.txt_Name.Enabled = false; } this.ListPager1.RecordCount = provider.GetSize(); this.BindSource(purchase, 0); } this.account.Text = GetAccout();// Session["LOGINED"].ToString(); this.datetime.Text = this.BindDayWeek(); this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange); }
protected void btn_Result_Click(object sender, EventArgs e) { Purchase purchase = new Purchase(); purchase.Good_Id = ""; purchase.Year_Month = 0; if (this.txt_Name.Text != "") { purchase.Good_Id = this.txt_Name.Text.ToString(); } if (this.txt_Yearmonth.Text != "") { purchase.Year_Month = Convert.ToInt32(this.txt_Yearmonth.Text); } PurchaseProvider provider = new PurchaseProvider(); this.ListPager1.RecordCount = provider.GetSize(purchase); this.BindSource(0, purchase.Good_Id, purchase.Year_Month); this.ListPager1.PageChange += new PagerEventHandler(ListPager1_PageChange); }
public async void CalculateAmountFromVat(decimal vatRate, decimal grossAmount, decimal netAmount, decimal vatAmount) { /* * Amount are correct according to the https://www.calkoo.com/en/vat-calculator, however there could be a rounding problem * Further clarification should needed to see this data is correct or not */ // Arrange var serviceProvider = ServiceProvider(); var purchaseProvider = new PurchaseProvider(null, serviceProvider.GetService <IGrossCalculator>() , serviceProvider.GetService <IVatCalculator>(), serviceProvider.GetService <INetCalculator>()); // Act var purchase = await purchaseProvider.GetPurchaseVatAsync( new Purchase { GrossAmount = null, NetAmount = null, VatAmount = vatAmount, VatRate = vatRate }); // Assert Assert.True(purchase.IsSuccess); Assert.NotNull(purchase.Purchase); Assert.Null(purchase.ErrorMessage); Assert.Equal(purchase.Purchase.GrossAmount, grossAmount); Assert.Equal(purchase.Purchase.NetAmount, netAmount); }
protected void btn_sure_Click(object sender, EventArgs e) { Purchase purchases = this.AddPurchase(); PurchaseProvider provider = new PurchaseProvider(); switch (this.OperationFlag) { case Operation.Add: if (purchases.Good_Id == "") { this.Alert("ÉÌÆ·±àºÅûÉèÖã¬Ìí¼Óʧ°Ü!!!"); break; } if (purchases.Staffinfo_Id == 0) { this.Alert("Ô±¹¤±àºÅΪ0£¬Ìí¼Óʧ°Ü!!!"); break; } if (this.IsSame() == 1) { break; } if (this.IsRang() == false) { break; } if (provider.Insert(purchases)) { StockProvider stockProvider = new StockProvider(); Stock stock = new Stock(); stock.Stock_Num = purchases.Purchase_Num; stock.Good_Id = purchases.Good_Id; stock.Stock_Oper = 1; stock.Staffinfo_Id = purchases.Staffinfo_Id; stock.Purchase_Price = purchases.Purchase_Price; stock.Purchase_Datetime = DateTime.Now.ToString("yyyyMMdd"); if (stockProvider.Insert(stock)) { this.Alert("Ìí¼Ó³É¹¦!!!"); this.TextCancel(); } } break; case Operation.Update: if (false == String.IsNullOrEmpty(purchases.Good_Id)) { this.Alert("²ÎÊý´íÎó£¬ÐÞ¸Äʧ°Ü!!!"); break; } if (this.IsRang() == false) { break; } if (provider.Update(purchases)) { this.Alert("Ð޸ijɹ¦!!!"); this.BindText(); } break; } }
protected void btn_Export_Click(object sender, EventArgs e) { System.Web.UI.WebControls.GridView dg = new System.Web.UI.WebControls.GridView(); /* * BoundField field1 = new BoundField(); * field1.DataField = "sale_id"; * field1.HeaderText = "销售单号"; * dg.Columns.Add(field1); * * BoundField field2 = new BoundField(); * field2.DataField = "good_id"; * field2.HeaderText = "商品编号"; * dg.Columns.Add(field2); * * BoundField field3 = new BoundField(); * field3.DataField = "sale_price"; * field3.HeaderText = "销售单价"; * dg.Columns.Add(field3); * * BoundField field4 = new BoundField(); * field4.DataField = "purchase_price"; * field4.HeaderText = "采购单价"; * dg.Columns.Add(field4); * * BoundField field5 = new BoundField(); * field5.DataField = "purchase_total"; * field5.HeaderText = "成本总价"; * dg.Columns.Add(field5); * * BoundField field6 = new BoundField(); * field6.DataField = "sale_num"; * field6.HeaderText = "销售数量"; * dg.Columns.Add(field6); * * * BoundField field7 = new BoundField(); * field7.DataField = "sale_total"; * field7.HeaderText = "销售总价"; * dg.Columns.Add(field7); * * BoundField field8 = new BoundField(); * field8.DataField = "sale_profit"; * field8.HeaderText = "利润"; * dg.Columns.Add(field8); * * BoundField field9 = new BoundField(); * field9.DataField = "sale_datetime"; * field9.HeaderText = "销售时间"; * dg.Columns.Add(field9); * * BoundField field10 = new BoundField(); * field10.DataField = "buyer_bh"; * field10.HeaderText = "采购商编号"; * dg.Columns.Add(field10); */ Purchase purchase = new Purchase(); purchase.Good_Id = ""; purchase.Year_Month = 0; if (this.txt_Name.Text != "") { purchase.Good_Id = this.txt_Name.Text.ToString(); } if (this.txt_Yearmonth.Text != "") { purchase.Year_Month = Convert.ToInt32(this.txt_Yearmonth.Text); } PurchaseProvider provider = new PurchaseProvider(); DataTable table = provider.Select(purchase, 0, 0); dg.DataSource = table.DefaultView; dg.DataBind(); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition", "attachment;filename=PurchaseRecords.xls"); Response.Charset = ""; this.EnableViewState = false; System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); dg.RenderControl(htw); Response.Write(sw.ToString()); Response.End(); }