/// <summary> /// 获取退货款信息 /// </summary> /// <param name="ID"></param> /// <param name="docID"></param> /// <returns></returns> public static InventoryDocModel GetInventory(int ID, string docID) { InventoryDocModel model = null; string sql = "select * from inventorydoc where id=@id and docid=@docid"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int, 20), new SqlParameter("@docid", SqlDbType.VarChar, 20) }; parameter[0].Value = ID; parameter[1].Value = docID; InventoryDocDetailsModel list = new InventoryDocDetailsModel(); SqlDataReader read = DBHelper.ExecuteReader(sql, parameter, CommandType.Text); while (read.Read()) { model = new InventoryDocModel(int.Parse(read["ID"].ToString())); model.DocID = read["DocID"].ToString(); model.Client = read["Client"].ToString(); model.TotalMoney = double.Parse(read["TotalMoney"].ToString()); model.Charged = decimal.Parse(read["Charged"].ToString()); model.Reason = read["Reason"].ToString(); } read.Close(); return(model); }
private void BindInfo(string billid) { InventoryDocModel idm = StorageInBLL.getOrderInfo(billid); this.txtAddress.Text = idm.Address.ToString(); this.txtpici.Text = idm.BatchCode.ToString(); this.txtOperationPerson.Text = idm.OperationPerson.ToString(); this.txtOriginalDocID.Text = idm.OriginalDocID.ToString(); this.txtMemo.Text = idm.Note.ToString(); this.ddlWareHouse.SelectedValue = idm.WareHouseID.ToString(); int wareHouseID = Convert.ToInt32(idm.WareHouseID.ToString()); this.ddlDepotSeat.SelectedValue = idm.DepotSeatID.ToString(); this.ddlProvider.SelectedValue = Convert.ToString(idm.Provider); //ddlCountry.SelectedValue = CountryBLL.GetCountryCodeByID(idm.Currency.ToString()); this.ViewState["billId"] = billid; DataTable dt = StorageInBLL.getProduct(billid); foreach (DataRow dr in dt.Rows) { InventoryDocDetailsModel model = new InventoryDocDetailsModel(); model.ProductID = int.Parse(dr["productid"].ToString()); model.UnitPrice = double.Parse(dr["unitprice"].ToString()); model.MeasureUnit = "0"; //model.Pici = dr["pici"].ToString(); model.ProductQuantity = double.Parse(dr["productquantity"].ToString()); list.Add(model); } Session["storageList"] = list; }
/// <summary> /// 退货单详细查询 /// Select * From InventoryDocDetails Where DocID=@cha_docID /// </summary> /// <param name="ID"></param> /// <returns></returns> public static List <InventoryDocDetailsModel> GetInventoryDoctails(string ID) { string sql = "Select * From InventoryDocDetails Where DocID=@DocID"; SqlParameter[] parameter = new SqlParameter[] { new SqlParameter("DocID", SqlDbType.VarChar, 20) }; parameter[0].Value = ID; List <InventoryDocDetailsModel> list = new List <InventoryDocDetailsModel>(); SqlDataReader read = DBHelper.ExecuteReader(sql, parameter, CommandType.Text); while (read.Read()) { InventoryDocDetailsModel model = new InventoryDocDetailsModel(int.Parse(read["docDetailsID"].ToString())); model.DocID = read["DocID"].ToString(); model.ProductID = int.Parse(read["ProductID"].ToString()); model.ProductQuantity = double.Parse(read["ProductQuantity"].ToString()); model.ExpectNum = int.Parse(read["ExpectNum"].ToString()); model.UnitPrice = double.Parse(read["UnitPrice"].ToString()); model.ProductID = int.Parse(read["ProductID"].ToString()); model.PV = double.Parse(read["PV"].ToString()); list.Add(model); } read.Close(); return(list.Count <= 0 ? null : list); }
/// <summary> /// 确认出库按钮。并生成出库单(Outstock.aspx) /// </summary> /// <param name="storeOrderID"></param> /// <returns></returns> public static string OutOrder(string storeOrderID, string outStorageOrderID, InventoryDocModel idm, InventoryDocDetailsModel ddm) { return(InventoryDocDAL.OutOrder(storeOrderID, outStorageOrderID, idm, ddm)); }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { if (isButton == "出库") { if (DropCurrery.SelectedItem != null) { string currency = DropCurrery.SelectedItem.Value; string storeOrderID = ((Label)GridView_BillOutOrder.SelectedRow.FindControl("Lab_StoreOrderID")).Text; Response.Redirect("Outstock.aspx?StoreOrderID=" + storeOrderID + "&title=" + GetTran("001164", "请填写出库单") + "&enable=N&isBut=CK&source=ck&Country=" + currency); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("000058", "请选择国家") + "');</script>"); } } else if (isButton == "查看") { string storeOrderID = ((Label)GridView_BillOutOrder.SelectedRow.FindControl("Lab_StoreOrderID")).Text; Response.Redirect("ViewStoreOrderD.aspx?storeOrderID=" + storeOrderID); } else if (isButton == "s查看") { string storeOrderID = ((Label)GridView2_BilloutOrder.SelectedRow.FindControl("sLab_StoreOrderID")).Text; Response.Redirect("ViewStoreOrder.aspx?storeOrderID=" + storeOrderID); } else if (isButton == "撤单") { string storeorderid = ((Label)GridView2_BilloutOrder.SelectedRow.FindControl("sLab_StoreOrderID")).Text; DataTable dt = DBHelper.ExecuteDataTable("select docid from InventoryDoc where StoreOrderID='" + storeorderid + "'"); int i = 0; foreach (DataRow dr in dt.Rows) { List <InventoryDocDetailsModel> l_ddm = new List <InventoryDocDetailsModel>(); DataTable l_odm = InventoryDocDetailsBLL.GetInventoryDocDetailsByDocID(dr[0].ToString()); //BillOutOrderBLL.GetOrderDetailModelList(dr[0].ToString()); foreach (DataRow row in l_odm.Rows) { InventoryDocDetailsModel ddm = new InventoryDocDetailsModel(); ddm.ProductID = Convert.ToInt32(row["ProductId"]); ddm.ProductQuantity = Convert.ToDouble(row["ProductQuantity"]); ddm.UnitPrice = Convert.ToDouble(row["UnitPrice"]); ddm.PV = Convert.ToDouble(row["PV"]); ddm.ProductTotal = Convert.ToDouble(row["totalPrice"]); ddm.MeasureUnit = ""; l_ddm.Add(ddm); } if (BillOutOrderBLL.SetQuashBillOutOrder(dr[0].ToString(), l_ddm, storeorderid)) { i++; } } if (i > 0) { GridView_BillOutOrder.Visible = false; GridView2_BilloutOrder.Visible = true; ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001168", "撤单成功!") + "');</script>"); Pager1.PageBind(0, 10, " StoreOrder so left outer join city on so.cpccode=city.cpccode ", @" isSent,StoreID,StoreOrderID,OutStorageOrderID,ExpectNum, OrderType, TotalMoney,TotalPv,IsCheckOut,PayMentDateTime,InceptPerson,InceptAddress,Telephone,Weight,Carriage,OrderDateTime,city.country,city.province,city.city, Description ", ViewState["condition"].ToString(), "StoreOrderID", "GridView2_BilloutOrder", "OrderDateTime", 0); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001171", "撤单失败!") + "');</script>"); } } }
protected void Button1_Click(object sender, EventArgs e) { if (DropDownList2.SelectedItem == null || DropDownList1.SelectedItem == null) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("001301", "请选择创库和库位!") + "')</script>"); this.Button1.Text = GetTran("001290", "确定出库"); } else { string err = ""; string PrepareProduct_PrepareTime = DateTime.Now.ToString(); string PrepareProduct_OperateNum = Session["Company"].ToString(); string PrepareProduct_OperateIP = Request.UserHostAddress; string outStorageOrderID = ""; string GroupCK = ""; string[] arrstoreOrderID = Request.QueryString["StoreOrderID"].ToString().Replace("'", "").Replace("-", "").Replace("/*", "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int k = 0; k < arrstoreOrderID.Length; k++) { outStorageOrderID = "CK" + OrderGoodsBLL.GetNewOrderID(); GroupCK = GroupCK + outStorageOrderID + ","; StoreOrderModel som = BillOutOrderBLL.GetStoreOrderModel_II(arrstoreOrderID[k]); List <OrderDetailModel> l_odm = BillOutOrderBLL.GetOrderDetailModelList(arrstoreOrderID[k]); string sql = "select isnull(m.number,'') number,s.storeid,s.sendway from storeorder s left join ordergoods o on s.storeorderid=o.fahuoorder left join memberorder m on o.memberorderid=m.orderid where s.storeorderid='" + arrstoreOrderID[k] + "'"; DataTable dt = DBHelper.ExecuteDataTable(sql); string sendway = dt.Rows[0]["sendway"].ToString(); string number = dt.Rows[0]["number"].ToString(); string storeid = dt.Rows[0]["storeid"].ToString(); InventoryDocModel idm = new InventoryDocModel(); //idm.DocAuditTime = som.AuditingDate; idm.DocTypeID = Convert.ToInt32(DAL.DBHelper.ExecuteScalar("select DocTypeId from dbo.DocTypeTable where DocTypeCode='CK'")); //出库单 idm.DocMaker = TextBox4.Text; if (sendway == "1") { idm.Client = number; } else { idm.Client = storeid; } idm.DepotSeatID = Convert.ToInt32(DropDownList2.SelectedItem.Value); idm.WareHouseID = Convert.ToInt32(DropDownList1.SelectedItem.Value); idm.ExpectNum = som.ExpectNum; idm.Note = TextBox6.Text.Trim(); idm.StateFlag = 1; idm.CloseFlag = 0; idm.OperationPerson = "";//业务员 idm.OriginalDocID = arrstoreOrderID[k]; idm.Address = som.InceptAddress; idm.Storeorderid = arrstoreOrderID[k]; List <InventoryDocDetailsModel> l_ddm = new List <InventoryDocDetailsModel>(); double totalmoney = 0; double totalpv = 0; foreach (RepeaterItem item in Repeater1.Items) { HiddenField HF = (HiddenField)item.FindControl("HF"); Label lblPrice = (Label)item.FindControl("lblPrice"); Label lblPV = (Label)item.FindControl("lblPV"); Label txtCount1 = (Label)item.FindControl("txtCount1"); TextBox txtCount = (TextBox)item.FindControl("txtCount"); int count = 0; int.TryParse(txtCount.Text, out count); if (count > 0) { if (Convert.ToInt32(txtCount.Text) > Convert.ToInt32(txtCount1.Text)) { ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('" + GetTran("007716", "出库数量不能大于剩余数量!") + "');", true); this.Button1.Text = GetTran("001290", "确定出库"); return; } if (Convert.ToInt32(DAL.DBHelper.ExecuteScalar("select COUNT(0) from OrderDetail where StoreOrderID='" + arrstoreOrderID[k] + "' and ProductID=" + Convert.ToInt32(HF.Value) + " and (Quantity-OutBillQuantity)<" + count)) > 0) { ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('" + GetTran("007716", "出库数量不能大于剩余数量!") + "');", true); this.Button1.Text = GetTran("001290", "确定出库"); loadData(); return; } InventoryDocDetailsModel ddm = new InventoryDocDetailsModel(); ddm.ProductID = Convert.ToInt32(HF.Value); ddm.ProductQuantity = Convert.ToInt32(txtCount.Text); ddm.UnitPrice = Convert.ToDouble(lblPrice.Text); ddm.PV = Convert.ToDouble(lblPV.Text); ddm.ProductTotal = Convert.ToDouble(txtCount.Text) * Convert.ToDouble(lblPrice.Text); ddm.MeasureUnit = ""; totalmoney += Convert.ToDouble(txtCount.Text) * Convert.ToDouble(lblPrice.Text); totalpv += Convert.ToDouble(txtCount.Text) * Convert.ToDouble(lblPV.Text); l_ddm.Add(ddm); } } idm.TotalMoney = totalmoney; idm.TotalPV = totalpv; if (l_ddm.Count <= 0) { string getcount = " select sum(quantity-outbillquantity) from orderdetail where storeorderid='" + arrstoreOrderID[k] + "'"; object ckk = DBHelper.ExecuteScalar(getcount, CommandType.Text); if (ckk.ToString() == null || ckk.ToString() == "") { ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('没有商品暂时没法出库!')", true); } else { if (int.Parse(ckk.ToString()) <= 0) { DBHelper.ExecuteNonQuery("update storeorder set IsGeneOutBill='A' where storeorderid='" + arrstoreOrderID[k] + "'"); } } ScriptManager.RegisterStartupScript(this, GetType(), "msg", "alert('" + GetTran("007721", "请输入出库数量!") + "')", true); this.Button1.Text = GetTran("001290", "确定出库"); return; } string rt = BillOutOrderBLL.OutOrder(arrstoreOrderID[k], outStorageOrderID, idm, l_ddm); if (rt == "1") { int hs = 0; string getcount = " select sum(quantity-outbillquantity) from orderdetail where storeorderid='" + arrstoreOrderID[k] + "'"; if (int.Parse(DBHelper.ExecuteScalar(getcount, CommandType.Text).ToString()) <= 0) { hs = DBHelper.ExecuteNonQuery("update storeorder set IsGeneOutBill='A' where storeorderid='" + arrstoreOrderID[k] + "'"); } else { hs = DBHelper.ExecuteNonQuery("update storeorder set IsGeneOutBill='Y' where storeorderid='" + arrstoreOrderID[k] + "'"); } if (hs == 1) { //PrepareProduct_DocIDs = PrepareProduct_DocIDs + arrstoreOrderID[k] + ","; //PrepareProduct_TotalMoney = PrepareProduct_TotalMoney + Convert.ToDouble(idm.TotalMoney); //PrepareProduct_TotalPv = PrepareProduct_TotalPv + Convert.ToDouble(idm.TotalPV); } else { err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007722", " 的产品出库失败!"); } } else if (rt == "0") { err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007723", " 的产品库存不够!"); } else if (rt == "-6") { err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007724", " 的产品仓库库位上没有货!"); } else if (rt == "-5") { err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007725", " 的产品更新出库数量错误!"); } else if (rt == "-88") { err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007726", " 的产品已经出库!"); } else { err = err + GetTran("000079", "订单号:") + arrstoreOrderID[k] + GetTran("007727", " 的产品出库失败!"); } } if (err == "") { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>if(window.confirm('" + GetTran("001297", "生成的出库单号为:") + outStorageOrderID + GetTran("001298", ",您要打印此出库单吗?") + "')) window.open('docPrint.aspx?docID=" + outStorageOrderID + "');window.location.href='BillOutOrder.aspx';</script>"); } else { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + err + "');window.location.href='BillOutOrder.aspx'</script>"); } this.Button1.Text = GetTran("001290", "确定出库"); } }
/// <summary> /// 读取用户的订货信息 /// </summary> /// <returns></returns> private bool GetOrderInfo() { //读取用户的订货信息 ViewState["zongPrice"] = 0; decimal zongPrice = 0; decimal zongPv = 0; ArrayList list = new ArrayList(); decimal price; decimal pv; int count; int id; if (gdvRefundment.Rows.Count <= 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002013", "对不起,库存中无可退的货!") + "')</script>"); return(false); } foreach (GridViewRow item in gdvRefundment.Rows) { Label lblName = (Label)item.FindControl("lblname"); //读取用户输入的数量 if (((TextBox)item.FindControl("TxtPdtNum")).Text != "") { try { count = Convert.ToInt32(((TextBox)item.FindControl("TxtPdtNum")).Text); } catch { //msg = ReturnAlert("对不起,订货信息请输入数字!"); ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002022", "对不起,订货信息请输入数字!") + "')</script>"); return(false); } } else { count = 0; } if (count > 0) { price = Convert.ToDecimal(((Label)item.FindControl("LblPrice")).Text); pv = Convert.ToDecimal(((Label)item.FindControl("LblPv")).Text); RadioButtonList radioList = ((RadioButtonList)item.FindControl("RadioBtnCate")); //根据用户所选单位计算出实际数量 count = count * Convert.ToInt32(radioList.SelectedValue); id = Convert.ToInt32(((Label)item.FindControl("LblHuoid")).Text); //判断店铺是否有足够库存 int left = returnedGoodsBLL.GetCertainProductLeftStoreCount(id.ToString(), txtStoreId.Text); if ((left - count) < 0) { //msg = ReturnAlert("对不起,此店的库存不够:" + ((Label)item.FindControl("lblname")).Text + " 的库存数只有:" + left); ClientScript.RegisterStartupScript(this.GetType(), "", "" + GetTran("002023", "对不起,此店的库存不够:") + "" + ((Label)item.FindControl("lblname")).Text + "" + GetTran("002024", "的库存数只有:") + " " + left); return(false); } //保存退货的产品明细信息 InventoryDocDetailsModel inventoryDocDetailsModel = new InventoryDocDetailsModel(); inventoryDocDetailsModel.DocID = ""; inventoryDocDetailsModel.ProductID = id; inventoryDocDetailsModel.ProductQuantity = Convert.ToDouble(count); inventoryDocDetailsModel.UnitPrice = Convert.ToDouble(price); inventoryDocDetailsModel.MeasureUnit = ""; inventoryDocDetailsModel.PV = Convert.ToDouble(pv); inventoryDocDetailsModel.ExpectNum = BLL.CommonClass.CommonDataBLL.getMaxqishu(); //inventoryDocDetailsModel.SelectedIndex = 1; inventoryDocDetailsModel.ProductTotal = Convert.ToDouble(price * count); list.Add(inventoryDocDetailsModel); zongPrice += price * count; zongPv += pv * count; } } //保存信息 ViewState["list"] = list; ViewState["zongPrice"] = zongPrice; ViewState["zongPv"] = zongPv; return(true); }
/// <summary> /// 修改金额 /// </summary> /// <param name="sun"></param> /// <param name="productid"></param> /// <param name="DepotSeatID"></param> /// <returns></returns> public static string ProductReportDamage(double sun, int productid, int warehouseid, int DepotSeatID, string mode, InventoryDocDetailsModel opda_docDetail) { InventoryDocDAL invent = new InventoryDocDAL(); return(invent.ProductReportDamage(sun, productid, warehouseid, DepotSeatID, mode, opda_docDetail)); }
//验证输入信息 private bool GetOrderInfo() { ViewState["zongPrice"] = 0; decimal zongPrice = 0; decimal zongPv = 0; int count = 0; decimal price = 0; decimal pv = 0; int id = 0; ArrayList list = new ArrayList(); //检查输入的数据是否合法, foreach (GridViewRow row in this.givproduct.Rows) { TextBox text = row.FindControl("txtPdtNum") as TextBox; if (text.Text.Trim() != "") { try { count += Convert.ToInt32(text.Text.Trim()); if (count < 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002003", "调拨数量必须为正整数!") + "');</script>"); return(false); } } catch { ScriptHelper.SetAlert(Page, GetTran("002006", "调拨数量请输入数字!")); return(false); } } } //判断是否输入要报损的数据 if (count == 0) { ScriptHelper.SetAlert(Page, GetTran("002007", "请输入调拨数量!")); return(false); } //检查单条数据 foreach (GridViewRow row in this.givproduct.Rows) { TextBox text = row.FindControl("txtPdtNum") as TextBox; //验证用户输入的是否是数字 if (text.Text.Trim() != "") { try { count = Convert.ToInt32(text.Text.Trim()); if (count < 0) { ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + GetTran("002003", "调拨数量必须为正整数!") + "');</script>"); return(false); } } catch { ScriptHelper.SetAlert(this.givproduct, GetTran("002006", "调拨数量请输入数字!")); return(false); } } else { count = 0; } if (count > 0) { price = Convert.ToDecimal(((Label)row.FindControl("LblPrice")).Text.Trim()); pv = Convert.ToDecimal(((Label)row.FindControl("LblPV")).Text.Trim()); RadioButtonList radiolist = row.FindControl("rdoBtnCate") as RadioButtonList; count = count * Convert.ToInt32(radiolist.SelectedValue); id = Convert.ToInt32((row.FindControl("lblhuoID") as Label).Text.Trim()); int wareDate = int.Parse((row.FindControl("WHouseDate") as Label).Text.Trim()); if (count > wareDate) { ScriptHelper.SetAlert(Page, GetTran("000501", "产品名称") + (row.FindControl("lblName") as Label).Text + GetTran("001859", "在该库位中的库存数量不足!")); return(false); } InventoryDocDetailsModel invert = new InventoryDocDetailsModel(); //invert.DepotSeatID = Convert.ToInt32(ddloutDepotSeatID.SelectedValue); invert.Batch = ""; invert.DocID = ""; invert.ExpectNum = Convert.ToInt32(Application["maxqishu"]); invert.MeasureUnit = "1"; invert.ProductID = id; invert.ProductQuantity = count; invert.ProductTotal = Convert.ToDouble(count * price); invert.PV = Convert.ToDouble(pv); //invert.SelectedIndex = 0; invert.UnitPrice = Convert.ToDouble(price); list.Add(invert); zongPrice += count * price; zongPv += pv * count; } } ViewState["list"] = list; ViewState["zongPrice"] = zongPrice; ViewState["zongPv"] = zongPv; return(true); }