private void button2_Click(object sender, EventArgs e) { try { string strSql = "select * from Mes_WorkShopWeight where W_Remark = '" + m_strBarcode + "'"; Mes_WorkShopWeightBLL WorkShopWeightBLL = new Mes_WorkShopWeightBLL(); Mes_WorkShopWeightEntity WorkShopWeightEntity = new Mes_WorkShopWeightEntity(); DataSet ds = new DataSet(); ds = WorkShopWeightBLL.GetList_WorkShop(strSql); if (ds.Tables[0].Rows.Count > 0) { string strOrderNo = ds.Tables[0].Rows[0]["W_OrderNo"].ToString(); string strGoodsCode = ds.Tables[0].Rows[0]["W_SecGoodsCode"].ToString(); string strBatch = ds.Tables[0].Rows[0]["W_SecBatch"].ToString(); string strQty = ds.Tables[0].Rows[0]["W_SecQty"].ToString(); decimal d = Convert.ToDecimal(strQty); strQty = d.ToString("0.####"); //string strPrice = dataGridView2.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["价格2"].Value.ToString(); string strGoodsName = ds.Tables[0].Rows[0]["W_SecGoodsName"].ToString(); string strBarcode = ds.Tables[0].Rows[0]["W_Remark"].ToString(); //string strDate = dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["W_Price"].Value.ToString(); if (MessageBox.Show("物料是否要补写?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes) { try { this.Enabled = false; Cursor.Current = Cursors.WaitCursor; GetImg("物料" + strGoodsCode + "批次" + strBatch + "单号" + Globels.strOrderNo, strGoodsName, strQty, strBZQ, strBarcode); //DeleteData(strId); //SaveBarcode(strBarcode, strGoodsCode, strGoodsName, Convert.ToDecimal(strQty), strWorkShop); this.Enabled = true; Cursor.Current = Cursors.Default; } catch (Exception ex) { this.Enabled = true; Cursor.Current = Cursors.Default; } } } else { MessageBox.Show("不好意思,您还没有打印过任何标签"); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); //lblTS.Text = "系统提示:请选中某一行进行补写"; } }
/// <summary> /// 保存实体数据 /// </summary> /// <param name="keyValue">主键</param> /// <param name="entity">实体</param> /// <returns>返回值大于0:操作成功</returns> public int SaveEntity(string keyValue, Mes_WorkShopWeightEntity entity) { try { var strSql = new StringBuilder(); var paramList = new List <SqlParameter>(); if (string.IsNullOrEmpty(keyValue)) { strSql.Append("INSERT INTO Mes_WorkShopWeight("); strSql.Append("ID,"); strSql.Append("W_RecordCode,"); strSql.Append("W_RecordName,"); strSql.Append("W_ProceCode,"); strSql.Append("W_ProceName,"); strSql.Append("W_WorkShopCode,"); strSql.Append("W_WorkShopName,"); strSql.Append("W_OrderNo,"); strSql.Append("W_Status,"); strSql.Append("W_CreateBy,"); strSql.Append("W_CreateDate,"); strSql.Append("W_SecGoodsCode,"); strSql.Append("W_SecGoodsName,"); strSql.Append("W_SecUnit,"); strSql.Append("W_SecQty,"); strSql.Append("W_SecBatch,"); strSql.Append("W_Remark"); strSql.Append(")"); strSql.Append(" VALUES ("); strSql.Append("@ID,"); strSql.Append("@W_RecordCode,"); strSql.Append("@W_RecordName,"); strSql.Append("@W_ProceCode,"); strSql.Append("@W_ProceName,"); strSql.Append("@W_WorkShopCode,"); strSql.Append("@W_WorkShopName,"); strSql.Append("@W_OrderNo,"); strSql.Append("@W_Status,"); strSql.Append("@W_CreateBy,"); strSql.Append("@W_CreateDate,"); strSql.Append("@W_SecGoodsCode,"); strSql.Append("@W_SecGoodsName,"); strSql.Append("@W_SecUnit,"); strSql.Append("@W_SecQty,"); strSql.Append("@W_SecBatch,"); strSql.Append("@W_Remark"); strSql.Append(")"); paramList.Add(new SqlParameter("@ID", Guid.NewGuid().ToString())); } else { } paramList.Add(new SqlParameter("@W_RecordCode", entity.W_RecordCode)); paramList.Add(new SqlParameter("@W_RecordName", entity.W_RecordName)); paramList.Add(new SqlParameter("@W_ProceCode", entity.W_ProceCode)); paramList.Add(new SqlParameter("@W_ProceName", entity.W_ProceName)); paramList.Add(new SqlParameter("@W_WorkShopCode", entity.W_WorkShopCode)); paramList.Add(new SqlParameter("@W_WorkShopName", entity.W_WorkShopName)); paramList.Add(new SqlParameter("@W_OrderNo", entity.W_OrderNo)); paramList.Add(new SqlParameter("@W_Status", entity.W_Status)); paramList.Add(new SqlParameter("@W_CreateBy", entity.W_CreateBy)); paramList.Add(new SqlParameter("@W_CreateDate", entity.W_CreateDate)); paramList.Add(new SqlParameter("@W_SecGoodsCode", entity.W_SecGoodsCode)); paramList.Add(new SqlParameter("@W_SecGoodsName", entity.W_SecGoodsName)); paramList.Add(new SqlParameter("@W_SecUnit", entity.W_SecUnit)); paramList.Add(new SqlParameter("@W_SecQty", entity.W_SecQty)); paramList.Add(new SqlParameter("@W_SecBatch", entity.W_SecBatch)); paramList.Add(new SqlParameter("@W_Remark", entity.W_Remark)); var result = db.ExecuteNonQuery(strSql.ToString(), paramList.ToArray()); return(result); } catch (Exception) { throw; } }
private void btnSave_Click(object sender, EventArgs e) { if (txtGoodsName.Text == "") { MessageBox.Show("请先选择物料"); return; } else { try { if (txtQty.Text == "") { MessageBox.Show("请先称重"); return; } if (txtRQQty.Text == "") { MessageBox.Show("请先输入容器重量"); return; } if (IsNumberic(txtRQQty.Text) == false) { MessageBox.Show("容器重量应该为数字"); return; } if (Convert.ToDecimal(txtRQQty.Text) > Convert.ToDecimal(txtQty.Text)) { MessageBox.Show("容器重量不能大于称重重量"); return; } this.Enabled = false; Cursor.Current = Cursors.WaitCursor; string strBarcode = txtCode.Text + DateTime.Now.ToString("yyyyMMddHHmmss"); Mes_WorkShopWeightBLL WorkShopWeightBLL = new Mes_WorkShopWeightBLL(); Mes_WorkShopWeightEntity WorkShopWeightEntity = new Mes_WorkShopWeightEntity(); WorkShopWeightEntity.W_CreateBy = ""; WorkShopWeightEntity.W_CreateDate = DateTime.Now; WorkShopWeightEntity.W_OrderNo = Globels.strOrderNo; WorkShopWeightEntity.W_ProceCode = Globels.strProce; WorkShopWeightEntity.W_ProceName = Globels.strProceName; WorkShopWeightEntity.W_RecordName = Globels.strRecordName; WorkShopWeightEntity.W_WorkShopName = Globels.strWorkShopName; WorkShopWeightEntity.W_RecordCode = Globels.strRecord; WorkShopWeightEntity.W_Remark = ""; WorkShopWeightEntity.W_SecBatch = txtBatch.Text; WorkShopWeightEntity.W_SecGoodsCode = txtCode.Text; WorkShopWeightEntity.W_SecGoodsName = txtGoodsName.Text; WorkShopWeightEntity.W_SecQty = Convert.ToDecimal(txtQty.Text) - Convert.ToDecimal(txtRQQty.Text); WorkShopWeightEntity.W_SecUnit = txtUnit.Text; WorkShopWeightEntity.W_Status = 1; WorkShopWeightEntity.W_WorkShopCode = Globels.strWorkShop; WorkShopWeightEntity.W_Remark = strBarcode; int nCount = WorkShopWeightBLL.SaveEntity("", WorkShopWeightEntity); if (nCount > 0) { string Barcode = txtCode.Text + DateTime.Now.ToString("yyyyMMddHHmmss"); m_strBarcode = Barcode; decimal dTemp = Convert.ToDecimal(txtQty.Text) - Convert.ToDecimal(txtRQQty.Text); GetImg("物料" + txtCode.Text + "批次" + txtBatch.Text.Trim() + "单号" + Globels.strOrderNo, txtGoodsName.Text, dTemp.ToString(), strBZQ, strBarcode); MessageBox.Show("添加成功"); SaveBarcode(Barcode, txtCode.Text, txtGoodsName.Text, dTemp, Globels.strWorkShop); } this.Enabled = true; Cursor.Current = Cursors.Default; } catch (Exception ex) { this.Enabled = true; Cursor.Current = Cursors.Default; } } }