/// <summary> /// 设置盘亏单数据 /// </summary> /// <param name="billNum">盘亏单单号</param> private void SetDataByCompleteLose(string billNum) { //修改标题 this.Title = "盘亏单预览" + billNum; //数据适配器 using (var daHead = new t_complete_lot_card_lose_headTableAdapter()) using (var daContent = new t_complete_lot_card_lose_contentTableAdapter()) { //获取表头数据 var tabHead = daHead.GetDataByBillNum(billNum); if (tabHead.Rows.Count > 0) { //首行数据 var row = (DataSetCompleteLose.t_complete_lot_card_lose_headRow)tabHead.Rows[0]; //设置值到控件 litBillType0.Text = litBillType1.Text = litBillType2.Text = "盘亏"; lblBillDate0.Text = lblBillDate1.Text = lblBillDate2.Text = row.bill_date.ToString("yyyy年MM月dd日"); lblBillNum0.Text = lblBillNum1.Text = lblBillNum2.Text = row.bill_num; litHeadProcName0.Text = litHeadProcName1.Text = litHeadProcName2.Text = string.Empty; lblHeadProcName0.Text = lblHeadProcName1.Text = lblHeadProcName2.Text = string.Empty; lblAddPerson0.Text = lblAddPerson1.Text = lblAddPerson2.Text = row.add_person; lblLastChangeTime0.Text = lblLastChangeTime1.Text = lblLastChangeTime2.Text = row.last_change_time.ToString("yyyy-MM-dd HH:mm:ss"); } //获取内容数据 var tabContent = daContent.GetDataByBillNum(billNum); //当前表格序号 for (int iTable = 0; iTable < 3; iTable++) { //当前表格控件 var tSon = (Table)this.FindControl("tabDataListSon" + iTable); //遍历行 foreach (DataSetCompleteIn.t_complete_lot_card_in_contentRow row in tabContent.Rows) { //取得当前行序号 Int32 i = Convert.ToInt32(row.row_id) - 1; //当前行 var rSon = tSon.Rows[i + 1]; //各显示数据的控件 var litLotId = (Literal)rSon.Cells[1].FindControl("litLotId" + i.ToString() + "_" + iTable); var litPrevProcName = (Literal)rSon.Cells[2].FindControl("litPrevProcName" + i.ToString() + "_" + iTable); var litProductNum = (Literal)rSon.Cells[3].FindControl("litProductNum" + i.ToString() + "_" + iTable); var litPnlQty = (Literal)rSon.Cells[4].FindControl("litPnlQty" + i.ToString() + "_" + iTable); var litPcsQty = (Literal)rSon.Cells[5].FindControl("litPcsQty" + i.ToString() + "_" + iTable); var litRemark = (Literal)rSon.Cells[6].FindControl("litRemark" + i.ToString() + "_" + iTable); //设置数据到控件 litLotId.Text = row.lot_id; litPrevProcName.Text = string.Empty; litProductNum.Text = row.product_num; litPnlQty.Text = row.pnl_qty <= 0 ? string.Empty : row.pnl_qty.ToString(); litPcsQty.Text = row.pcs_qty <= 0 ? string.Empty : row.pcs_qty.ToString(); litRemark.Text = row.IsremarkNull() ? string.Empty : row.remark; } } } }
protected void fvCompleteLoseAdd_DataBound(object sender, EventArgs e) { //设置单据清单可见 tabDataListSon.Visible = true; //清空盘亏单内容清单 for (int i = 0; i < 10; i++) { //清空清单数据到控件 ClearBillContent(i); } //新增状态 switch (fvCompleteLoseAdd.CurrentMode) { //新增状态 case FormViewMode.Insert: //当前单号文本框 var tb = (TextBox)fvCompleteLoseAdd.FindControl("txtBillDate"); if (tb != null) { //检查用户提供的单据日期参数标识 string strBillDate = Request["bdate"]; DateTime billDate; if (strBillDate != null && strBillDate.Length > 0 && DateTime.TryParse(strBillDate, out billDate)) { //设置默认单据日期为传入的日期 tb.Text = billDate.ToString("yyyy-MM-dd"); } else { //设置默认单据日期为当前日期 tb.Text = DateTime.Now.ToString("yyyy-MM-dd"); } } //当前单号文本框 tb = (TextBox)fvCompleteLoseAdd.FindControl("txtBillNum"); if (tb != null) { //户提供的单号参数标识 string strBillNum = Request["bnum"]; Int64 billNum; if (strBillNum != null && strBillNum.Trim().Length >= 12 && Int64.TryParse(strBillNum, out billNum)) { //设置默认单号为传入的单号加1 tb.Text = (billNum + 1).ToString(); } else { //当前单号前缀字符串 string billNumPrefix = DateTime.Now.ToString("yyyyMMdd"); //数据适配器 using (var da = new t_complete_lot_card_lose_headTableAdapter()) { //获取已经使用的最大单号 string maxBillNum = da.GetMaxBillNumLikeBillNum(billNumPrefix + "%").ToString(); //检测取得的值 if (maxBillNum.Trim().Length < 12) { //执行转换 billNum = Int64.Parse(billNumPrefix + "0001"); //设置默认单号为传入的单号加1 tb.Text = billNum.ToString(); } else { //执行转换 billNum = Int64.Parse(maxBillNum); //设置默认单号为传入的单号加1 tb.Text = (billNum + 1).ToString(); } } } } //当前部门名称 var lit = (Literal)fvCompleteLoseAdd.FindControl("litProcName"); if (lit != null) { //session中保存的当前部门 string procName = Session["proc_name"].ToString(); //写入到客户端 lit.Text = procName; } //获取是否传入了多个已入库结存表的id值 string strIdAll = Request["ids"]; if (strIdAll != null && strIdAll.Trim().Length > 0) { //分解出id号 string[] strIds = strIdAll.Split(new char[] { '|' }, 10, StringSplitOptions.RemoveEmptyEntries); //检测id号数量 if (strIds.Length > 0) { //已入库结存表数据适配器 using (var da = new t_complete_lot_card_balanceTableAdapter()) { //当前子表行索引 int iRow = 0; //逐行获取数据 foreach (var strId in strIds) { //检测id Int64 id; if (Int64.TryParse(strId, out id)) { //取得数据 var tab = da.GetDataById(id); //检测有无数据 if (tab.Rows.Count > 0) { //首行数据 var row = (DataSetCompleteBalance.t_complete_lot_card_balanceRow)tab.Rows[0]; //写入清单数据到控件 SetBillContent(row, iRow); //行号加1 iRow++; } } } } } } break; case FormViewMode.Edit: case FormViewMode.ReadOnly: //设置单据清单不可见 tabDataListSon.Visible = false; //通过盘亏单号获取数据清单 //取得传入的盘亏单号 string billNum2 = Request["bnum"]; if (billNum2 != null && billNum2.Length > 0) { //获取清单 using (var daContent = new t_complete_lot_card_lose_contentTableAdapter()) { //获取数据 var tabContent = daContent.GetDataByBillNum(billNum2); //检测是否找到数据 if (tabContent.Rows.Count > 0) { //设置单据清单可见 tabDataListSon.Visible = true; //把内容写入页面 foreach (DataSetCompleteLose.t_complete_lot_card_lose_contentRow row in tabContent.Rows) { //当前行号 int i = row.row_id - 1; //写入清单数据到控件 SetBillContent(row, i); } } } } break; } //当前批量卡号文本框获取焦点 var tb2 = (TextBox)fvCompleteLoseAdd.FindControl("txtLotId0"); if (tb2 != null) { //设置焦点 tb2.Focus(); } }