/// <summary> /// 得到行项数据 /// </summary> public void GetRows() { try { foreach (ListViewRow Row in ListATs.Rows) { frmAssPORowLayout layout = Row.Control as frmAssPORowLayout; if (layout != null) { AssRowInputDto rowInputDto = Rows.Find(a => a.TEMPLATEID == layout.LblTId.Text); rowInputDto.QUANT = (decimal)layout.numQuant.Value; rowInputDto.PRICE = (decimal)layout.numPrice.Value; if (rowInputDto.QUANT == 0 || rowInputDto.PRICE == 0) { errorInfo = "请保证行项中的数量和单价均不为0!"; throw new Exception("请保证行项中的数量和单价均不为0!"); } } } } catch (Exception ex) { Toast(ex.Message); } }
/// <summary> /// 界面初始化时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmAssTemplateChoose_Load(object sender, EventArgs e) { try { AllATTable = _autofacConfig.SettingService.GetAllAssTemps(); foreach (DataRow row in AllATTable.Rows) { string TId = row["TEMPLATEID"].ToString(); AssRowInputDto inputDto = Rows.Find(a => a.TEMPLATEID == TId); if (inputDto != null) { row["IsChecked"] = true; row["PRICE"] = inputDto.PRICE; row["QUANT"] = inputDto.QUANT; } } DataColumn[] keys = new DataColumn[1]; keys[0] = AllATTable.Columns["TEMPLATEID"]; AllATTable.PrimaryKey = keys; UserId = Client.Session["UserID"].ToString(); Bind(null); } catch (Exception ex) { Toast(ex.Message); } }
/// <summary> /// 扫描到资产模板编号时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void bsAss_BarcodeScanned(object sender, BarcodeResultArgs e) { try { if (string.IsNullOrEmpty(e.error)) { String templateId = e.Value; AssTemplate assTemplate = _autofacConfig.SettingService.GetAtbyId(templateId); if (assTemplate != null) { if (TemplateIds.Contains(templateId)) { throw new Exception("该模板已添加,请勿重复添加!"); } else { TemplateIds.Add(templateId); decimal price = 0; if (assTemplate.PRICE != null) { price = assTemplate.PRICE.Value; } AssRowInputDto rowInputDto = new AssRowInputDto { TEMPLATEID = templateId, QUANT = 0, PRICE = 0, TPRICE = price, IMAGE = assTemplate.IMAGE, NAME = assTemplate.NAME }; Rows.Add(rowInputDto); Bind(); } } else { throw new Exception("编号为" + templateId + "模板不存在,请检查!"); } } } catch (Exception ex) { Toast(ex.Message); } }
/// <summary> /// 得到行项数据 /// </summary> private void GetAT() { try { //先保存当前页数据 GetRow(); //从AllATTale获取所需数据 Rows.Clear(); foreach (DataRow row in AllATTable.Rows) { AssRowInputDto rowInputDto = new AssRowInputDto(); if (bool.Parse(row["IsChecked"].ToString())) { rowInputDto.TEMPLATEID = row["TEMPLATEID"].ToString(); rowInputDto.IMAGE = row["IMAGE"].ToString(); rowInputDto.QUANT = decimal.Parse(row["QUANT"].ToString()); rowInputDto.NAME = row["NAME"].ToString(); rowInputDto.PRICE = decimal.Parse(row["PRICE"].ToString()); if (rowInputDto.QUANT == 0 || rowInputDto.PRICE == 0) { errorInfo = "请保证行项中的数量和单价均不为0!"; throw new Exception("请保证行项中的数量和单价均不为0!"); } // rowInputDto.TPRICE = decimal.Parse(row["TPRICE"].ToString()); Rows.Add(rowInputDto); } } } catch (Exception ex) { Toast(ex.Message); } }