/// <summary>
 /// 保存实体数据
 /// </summary>
 /// <param name="keyValue">主键</param>
 /// <param name="entity">实体</param>
 /// <returns>返回值大于0:操作成功</returns>
 public int SaveEntity(string keyValue, Mes_InWorkShopDetailEntity entity)
 {
     try
     {
         var strSql    = new StringBuilder();
         var paramList = new List <SqlParameter>();
         if (string.IsNullOrEmpty(keyValue))
         {
             strSql.Append("INSERT INTO Mes_InWorkShopDetail(");
             strSql.Append("ID,");
             strSql.Append("I_InNo,");
             strSql.Append("I_GoodsCode,");
             strSql.Append("I_GoodsName,");
             strSql.Append("I_Unit,");
             strSql.Append("I_Qty,");
             strSql.Append("I_Batch,");
             strSql.Append("I_Remark,");
             strSql.Append("I_Price");
             strSql.Append(")");
             strSql.Append(" VALUES (");
             strSql.Append("@ID,");
             strSql.Append("@I_InNo,");
             strSql.Append("@I_GoodsCode,");
             strSql.Append("@I_GoodsName,");
             strSql.Append("@I_Unit,");
             strSql.Append("@I_Qty,");
             strSql.Append("@I_Batch,");
             strSql.Append("@I_Remark,");
             strSql.Append("@I_Price");
             strSql.Append(")");
             paramList.Add(new SqlParameter("@ID", Guid.NewGuid().ToString()));
         }
         else
         {
             strSql.Append("UPDATE Mes_InWorkShopDetail SET ");
             strSql.Append("B_BasketCode=@B_BasketCode,");
             strSql.Append("B_BasketName=@B_BasketName,");
             strSql.Append("M_Weight=@M_Weight ");
             strSql.Append(" WHERE ID=@ID");
             paramList.Add(new SqlParameter("@ID", keyValue));
         }
         paramList.Add(new SqlParameter("@I_InNo", entity.I_InNo));
         paramList.Add(new SqlParameter("@I_GoodsCode", entity.I_GoodsCode));
         paramList.Add(new SqlParameter("@I_GoodsName", entity.I_GoodsName));
         paramList.Add(new SqlParameter("@I_Unit", entity.I_Unit));
         paramList.Add(new SqlParameter("@I_Qty", entity.I_Qty));
         paramList.Add(new SqlParameter("@I_Batch", entity.I_Batch));
         paramList.Add(new SqlParameter("@I_Remark", entity.I_Remark));
         paramList.Add(new SqlParameter("@I_Price", entity.I_Price));
         var result = db.ExecuteNonQuery(strSql.ToString(), paramList.ToArray());
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("是否要提交", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                {
                    Mes_InWorkShopTempBLL InWorkShopTempBLL = new Mes_InWorkShopTempBLL();
                    var rows = InWorkShopTempBLL.GetList_InWorkShopTemp("where I_StockCode = '" + cmbStock.Text + "' and I_WorkShop = '" + cmbWorkShop.Text + "' and I_OrderNo = '" + comOrderNo.Text + "'");
                    if (rows == null || rows.Count < 1)
                    {
                        //untCommon.InfoMsg("没有任何数据!");
                        lblTS.Text = "系统提示:没有任何数据!";
                        return;
                    }

                    Mes_InWorkShopHeadBLL      InWorkShopHeadBLL      = new Mes_InWorkShopHeadBLL();
                    Mes_InWorkShopDetailBLL    InWorkShopDetailBLL    = new Mes_InWorkShopDetailBLL();
                    Mes_InWorkShopHeadEntity   InWorkShopHeadEntity   = new Mes_InWorkShopHeadEntity();
                    Mes_InWorkShopDetailEntity InWorkShopDetailEntity = new Mes_InWorkShopDetailEntity();

                    string            strIn_No       = "";
                    MesMaterInHeadBLL MaterInHeadBLL = new MesMaterInHeadBLL();
                    strIn_No = MaterInHeadBLL.GetDH("车间入库到线边仓单");

                    InWorkShopHeadEntity.I_InNo       = strIn_No;
                    InWorkShopHeadEntity.I_OrderNo    = comOrderNo.Text;
                    InWorkShopHeadEntity.I_StockCode  = cmbStock.Text;
                    InWorkShopHeadEntity.I_StockName  = cmbStockName.Text;
                    InWorkShopHeadEntity.I_CreateBy   = "";
                    InWorkShopHeadEntity.I_CreateDate = DateTime.Now;
                    InWorkShopHeadEntity.I_OrderDate  = txtOrderDate.Text;
                    InWorkShopHeadEntity.I_Remark     = "";
                    InWorkShopHeadEntity.I_Status     = 1;
                    InWorkShopHeadEntity.I_WorkShop   = cmbWorkShop.Text;

                    int nRow = InWorkShopHeadBLL.SaveEntity("", InWorkShopHeadEntity);

                    for (int i = 0; i < rows.Count; i++)
                    {
                        InWorkShopDetailEntity.I_GoodsCode = rows[i].I_GoodsCode;
                        InWorkShopDetailEntity.I_GoodsName = rows[i].I_GoodsName;
                        InWorkShopDetailEntity.I_InNo      = strIn_No;
                        InWorkShopDetailEntity.I_Price     = rows[i].I_Price;
                        InWorkShopDetailEntity.I_Qty       = rows[i].I_Qty;
                        InWorkShopDetailEntity.I_Remark    = rows[i].I_Remark;
                        InWorkShopDetailEntity.I_Unit      = rows[i].I_Unit;
                        InWorkShopDetailEntity.I_Batch     = rows[i].I_Batch;
                        nRow = InWorkShopDetailBLL.SaveEntity("", InWorkShopDetailEntity);
                    }
                    //更改临时数据状态
                    Upload(strIn_No);
                    MessageBox.Show("保存成功");
                    lblTS.Text = "";
                    DeleteData();
                    UpdataNew();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }