Example #1
0
        /// <summary>
        /// 添加成功,初始化
        /// </summary>
        /// <param name="tempcmbStockNo"></param>
        private void Init(string tempcmbStockNo)
        {
            //检索该单据的行明细是否全部收货,如果全部收货,则更新表头 单据状态为R 已入库
            string       sql3 = "SELECT U_SFSH FROM " + ConnModel.commonDB + " ..[@SBO_ZJD_H] WHERE DocEntry =@docentry";
            SqlParameter ps3  = new SqlParameter("@docentry", tempcmbStockNo);
            DataTable    tbl3 = SqlHelper.GetDataTable(sql3, CommandType.Text, ps3);

            if (tbl3.Rows.Count > 0)
            {
                int i = 0;
                int j = 0;
                for (i = 0; i <= tbl3.Rows.Count - 1; i++)
                {
                    if (tbl3.Rows[i]["U_SFSH"].ToString() == "Y")
                    {
                        j = j + 1;
                    }
                }
                if (j == tbl3.Rows.Count)
                {
                    string       sql4 = "UPDATE " + ConnModel.commonDB + ".. [@SBO_ZJD] SET U_DJZT = 'R' WHERE  DocEntry =@docentry";
                    SqlParameter ps4  = new SqlParameter("@docentry", tempcmbStockNo);
                    SqlHelper.ExecuteNonquery(sql4, CommandType.Text, ps4);
                }
            }
            QRCode.Focus();
            CusTraceNo.Text = "";
            txtSyb.Text     = "";
            QRCode.Text     = string.Empty;
            Number.Text     = string.Empty;
        }
Example #2
0
 /// <summary>
 /// 清空按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button1_Click(object sender, EventArgs e)
 {
     QRCode.Text     = string.Empty;
     Number.Text     = string.Empty;
     CusTraceNo.Text = string.Empty;
     QRCode.Focus();
 }
Example #3
0
 /// <summary>
 /// 窗体加载
 /// </summary>
 private void LoadForm()
 {
     txtBC.Text = DateTime.Now.ToString("yyyyMMdd");
     tb_Quantity.Text = "";
     QRCode.Text = string.Empty;
     QRCode.Focus();
     ckwg.Checked = false;
     DGpro.DataSource = null;
 }
Example #4
0
        /// <summary>
        /// 添加到PC
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddRow_Click(object sender, EventArgs e)
        {
            try
            {
                if (tbl.Rows.Count == 0)
                {
                    QRCode.Focus();
                    throw new Exception("请先选择质检单号!");
                }
                //添加数据
                string str            = Convert.ToString(cmbStockNo.Text.Trim());
                char[] separator      = { '-' };
                string tempcmbStockNo = str.Split(separator)[0];
                if (tbl.Rows.Count > 0)
                {
                    List <string> list       = new List <string>();
                    string        sqlStr     = string.Empty;
                    string        rukuNumStr = string.Empty;
                    for (int i = 0; i < tbl.Rows.Count; i++)
                    {
                        rukuNumStr = tbl.Rows[i]["入库数量"].ToString();
                        if (!string.IsNullOrEmpty(rukuNumStr) && Convert.ToDouble(rukuNumStr) > 0)
                        {
                            sqlStr = string.Empty;
                            string itemcode     = tbl.Rows[i]["物料编码"].ToString();
                            string itemname     = tbl.Rows[i]["物料名称"].ToString();
                            double quantity     = Convert.ToDouble(tbl.Rows[i]["合格数量"].ToString());
                            double ruKuNum      = Convert.ToDouble(rukuNumStr);
                            int    checknumline = Convert.ToInt32(tbl.Rows[i]["质检单行号"].ToString());
                            string buynum       = tbl.Rows[i]["采购订单"].ToString();
                            int    buynumline   = Convert.ToInt32(tbl.Rows[i]["采购订单行号"].ToString());
                            string pici         = tbl.Rows[i]["批次"].ToString();
                            string custraceno   = CusTraceNo.Text.ToString();
                            string nowtime      = System.DateTime.Now.ToString("yyyyMMdd");
                            string qrcode       = itemcode + " " + nowtime;
                            string sql1         = string.Format("select count(1) from InCome where BuyNum='{0}' AND BuyNumLine={1} AND IsImport=0", buynum, buynumline);
                            object rtnValue     = SqlHelper.ExecuteScalar(sql1, CommandType.Text);
                            if (rtnValue != null && Convert.ToInt32(rtnValue) > 0)
                            {
                                sqlStr = String.Format("UPDATE InCome SET RuKuNum=ISNULL(RuKuNum,0)+{0} where BuyNum='{1}' AND BuyNumLine={2} AND IsImport=0", ruKuNum, buynum, buynumline);
                            }
                            else//增加
                            {
                                sqlStr = String.Format("INSERT INTO InCome(CheckNum,ItemCode,ItemName,QuanTity,CheckNumLine,BuyNum,BuyNumLine,CardCode,CusTraceNo,BatchNum,QRCode,RuKuNum) values ('{0}','{1}','{2}',{3},{4},'{5}',{6},'{7}','{8}','{9}','{10}',{11})", tempcmbStockNo, itemcode, itemname, quantity, checknumline, buynum, buynumline, cardcode, custraceno, pici, qrcode, ruKuNum);
                            }

                            list.Add(sqlStr);
                            if (ruKuNum >= quantity)
                            {
                                sqlStr = String.Format("UPDATE {0}.. [@SBO_ZJD_H] SET U_SFSH = 'Y',U_WQSL = 0 WHERE  DocEntry ='{1}' and LineId = {2}", ConnModel.commonDB, tempcmbStockNo, checknumline);
                            }
                            else
                            {
                                sqlStr = String.Format("UPDATE {0}.. [@SBO_ZJD_H] SET U_WQSL = {3} WHERE  DocEntry ='{1}' and LineId = {2}", ConnModel.commonDB, tempcmbStockNo, checknumline, quantity - ruKuNum);
                            }

                            list.Add(sqlStr);
                        }
                    }
                    if (list != null && list.Count > 0)
                    {
                        if (SqlHelper.ExecuteSqlTran(list) > 0)
                        {
                            tbl = null;
                            Init(tempcmbStockNo);
                            MessageBox.Show("添加成功...");
                        }
                        else
                        {
                            MessageBox.Show("添加失败...");
                        }
                    }
                    else
                    {
                        MessageBox.Show("无入库项!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("发生错误:" + ex.Message);
            }
        }