Exemple #1
0
        /// <summary>
        /// 输入来源单据后回车
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void txtSource_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13 && txtSource.Text.Length > 0)
            {
                string errMsg = null;
                try
                {
                    Cursor.Current = Cursors.WaitCursor;
                    if (SaleOutRedBusiness.VerifyGSPBack(txtSource.Text, out saleoutredlist, out errMsg))
                    {
                        btnSource.Enabled = true;
                        //txtCPosition.Enabled = true;
                        //txtCPosition.Focus();

                        ///判断当前仓库集合中是否有该单据的仓库,若没有则表明该用户无权操作。
                        string cwhcode = saleoutredlist.U8Details[0].cwhcode;
                        bool   flag    = false;
                        foreach (Warehouse w in Common.s_Warehouse)
                        {
                            if (w.cwhcode == cwhcode)
                            {
                                cmbWarehouse.SelectedItem = w;
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)//如果没有找到对应的仓库
                        {
                            MessageBox.Show("该单据您无权操作!");
                            return;
                        }

                        cmbWarehouse_SelectedIndexChanged(sender, e);
                        //检验单文本框不再可用
                        txtSource.Enabled = false;
                    }
                    else
                    {
                        MessageBox.Show("检验单错误:" + errMsg);
                        btnSource.Enabled = false;
                        //txtLable.Enabled = false;
                        txtSource.SelectAll();
                        txtSource.Focus();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    btnSource.Enabled = false;
                    //txtLable.Enabled = false;
                    txtSource.SelectAll();
                    txtSource.Focus();
                }
                finally
                {
                    Cursor.Current = Cursors.Default;
                }
            }
        }
Exemple #2
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     //判断已扫描数量是否完整
     //同一个存货同一个批次的数量必须相等
     //首先循环来源单据
     foreach (SaleOutRedDetail detail in saleoutredlist.U8Details)
     {
         decimal scannum = 0;
         //从已扫描数量中查找存货编码与批次相同的记录,最后判断数量是否相等
         var v = from od in saleoutredlist.OperateDetails where od.cinvcode == detail.cinvcode && od.cbatch == detail.cbatch select od;
         foreach (SaleOutRedDetail temp in v)
         {
             //累加已扫描数量
             scannum += temp.inewquantity;
         }
         if (scannum != detail.iquantity)
         {
             MessageBox.Show(string.Format("货物:{0}的数量与单据数量不符!", detail.cinvname));
             return;
         }
     }
     saleoutredlist.cmaker  = Common.CurrentUser.UserName;
     saleoutredlist.cwhcode = cmbWarehouse.SelectedValue.ToString();
     //监管码
     saleoutredlist.cdefine10 = txtRegCode.Text.Trim();
     try
     {
         this.Enabled   = false;
         Cursor.Current = Cursors.WaitCursor;
         string errMsg = "";
         int    rt     = SaleOutRedBusiness.SaveSaleOutRed(saleoutredlist, out errMsg);
         if (rt == 0)
         {
             MessageBox.Show("提交成功!");
         }
         else
         {
             MessageBox.Show("提交失败!" + errMsg);
         }
         Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("提交失败!" + ex.Message);
     }
     finally
     {
         this.Enabled   = true;
         Cursor.Current = Cursors.Default;
     }
 }