/// <summary>
        /// 保存
        /// </summary>
        /// <param name="SaveType">1-保存 2-保存并审核</param>
        /// <returns></returns>
        private bool SaveData(int SaveType)
        {
            txtRemark.Focus();
            gridView1.UpdateCurrentRow();

            if (txtDrawPerson.Text.Trim() == "")
            {
                this.ShowAlertMessage("必须输入领料人!");
                return(false);
            }

            if (dtpExcessOrderDate.Text == "")
            {
                this.ShowAlertMessage("必须输入开单日期!");
                return(false);
            }

            //if (txtEmitPerson.Text.Trim() == "")
            //{
            //    this.ShowAlertMessage("必须输入发料人!");
            //    return false;
            //}

            if (txtOutStorage.Text.Trim() == "")
            {
                this.ShowAlertMessage("必须输入领料仓库!");
                return(false);
            }


            if (gridView1.RowCount <= 0)
            {
                this.ShowAlertMessage("必须增加明细数据!");
                return(false);
            }


            //-------------------------------------
            //是否开启数量超出库存预警
            if (MaterialManage.OverNumStorage(txtOutStorage.Tag.ToString()) == true)
            {
                List <YJMaterialStorage> lst = IsOverStorageNum();
                if (lst.Count > 0)
                {
                    frmShowYJMaterial frmShowYJMaterial = new frmShowYJMaterial();
                    frmShowYJMaterial.ShowFillData(lst);
                    return(false);
                }
            }
            //---------------------------------------


            //if (bm.IsExistBillID(txtBillID.Text) == true && this.Tag.ToString() == "add")
            //{
            //    this.ShowAlertMessage("订单号已经存在,请重新输入!");
            //    return;
            //}


            ExcessOrder ExcessOrder = new ExcessOrder();

            ExcessOrder.ExcessOrderGuid = txtExcessOrderGuid.Text;
            ExcessOrder.ExcessOrderID   = txtExcessOrderID.Text;
            ExcessOrder.ExcessOrderDate = DateTime.Parse(dtpExcessOrderDate.Text);
            if (txtDrawPerson.Tag != null)
            {
                ExcessOrder.DrawPerson = txtDrawPerson.Tag.ToString();
            }
            if (txtEmitPerson.Tag != null)
            {
                ExcessOrder.EmitPerson = txtEmitPerson.Tag.ToString();
            }
            if (txtOutStorage.Tag != null)
            {
                ExcessOrder.OutStorage = txtOutStorage.Tag.ToString();
            }
            // ExcessOrder.OutStorage = "99999"; //由于要去除仓库,所以这边只是随便取一个仓库,basicdata中的 623 临时仓库

            ExcessOrder.Remark = txtRemark.Text;

            ExcessOrder.CreateGuid = txtCreateGuid.Tag.ToString();
            ExcessOrder.CreateDate = DateTime.Now;
            ExcessOrder.CheckGuid  = "";
            ExcessOrder.CheckDate  = DateTime.Parse("1900-01-01");
            ExcessOrder.CheckGuid2 = "";
            ExcessOrder.CheckDate2 = DateTime.Parse("1900-01-01");



            List <ExcessOrderDetail> list = new List <ExcessOrderDetail>();
            ExcessOrderDetail        ExcessOrderDetail = new ExcessOrderDetail();

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                ExcessOrderDetail = new ExcessOrderDetail();
                ExcessOrderDetail.ExcessOrderGuid = txtExcessOrderGuid.Text;
                ExcessOrderDetail.MaterialGuID    = dr["MaterialGuID"].ToString();
                if (dr["MaterialSum"].ToString().Trim() != "")
                {
                    ExcessOrderDetail.MaterialSum = decimal.Parse(dr["MaterialSum"].ToString());
                }
                else
                {
                    ExcessOrderDetail.MaterialSum = 0;
                }

                if (dr["MaterialOutSum"].ToString().Trim() != "")
                {
                    ExcessOrderDetail.MaterialOutSum = decimal.Parse(dr["MaterialOutSum"].ToString());
                }
                else
                {
                    ExcessOrderDetail.MaterialOutSum = 0;
                }
                ExcessOrderDetail.SortID = i;

                list.Add(ExcessOrderDetail);
            }



            //保存
            ExcessOrderManage.SaveBill(ExcessOrder, list);

            tsbCheck.Enabled   = true;
            tsbUnCheck.Enabled = false;

            SetRight();

            //写日志
            SysLog.AddOperateLog(SysParams.UserName, "超领单保存", "保存", SysParams.UserName + "用户保存了超领单,超领单唯一号:" + txtExcessOrderGuid.Text + "超领单号:" + txtExcessOrderID.Text);


            //用于打印
            DataTable dtl3 = base.GetDataTable((DataView)gridView1.DataSource);

            ds.Tables.Clear();
            ds.Tables.Add(dtl3.Copy());
            ds.Tables[0].TableName = "ExcessOrderDetail";

            this.Tag = "edit";

            if (SaveType == 1)
            {
                this.ShowMessage("保存成功");
            }

            frmExcessOrder.frmexcessorder.LoadData();

            return(true);
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="SaveType">保存类型:1-保存 2-审核并保存</param>
        /// <returns></returns>
        private bool SaveData(int SaveType)
        {
            txtRemark.Focus();
            gridView1.UpdateCurrentRow();

            if (txtDrawPerson.Text.Trim() == "")
            {
                this.ShowAlertMessage("必须输入领料人!");
                return(false);
            }

            if (dtpDrawOrderDate.Text == "")
            {
                this.ShowAlertMessage("必须输入开单日期!");
                return(false);
            }

            // if (txtEmitPerson.Text.Trim() == "")
            //{
            //    this.ShowAlertMessage("必须输入发料人!");
            //    return;
            // }

            if (txtOutStorage.Text.Trim() == "")
            {
                this.ShowAlertMessage("必须输入领料仓库!");
                return(false);
            }


            if (gridView1.RowCount <= 0)
            {
                this.ShowAlertMessage("必须增加明细数据!");
                return(false);
            }


            //-------------------------------------
            //是否开启数量超出库存预警
            if (MaterialManage.OverNumStorage(txtOutStorage.Tag.ToString()) == true)
            {
                List <YJMaterialStorage> lst = IsOverStorageNum();
                if (lst.Count > 0)
                {
                    frmShowYJMaterial frmShowYJMaterial = new frmShowYJMaterial();
                    frmShowYJMaterial.ShowFillData(lst);
                    return(false);
                }
            }
            //---------------------------------------

            //if (bm.IsExistBillID(txtBillID.Text) == true && this.Tag.ToString() == "add")
            //{
            //    this.ShowAlertMessage("订单号已经存在,请重新输入!");
            //    return;
            //}


            DrawOrder DrawOrder = new DrawOrder();

            DrawOrder.DrawOrderGuid = txtDrawOrderGuid.Text;
            DrawOrder.DrawOrderID   = txtDrawOrderID.Text;
            DrawOrder.DrawOrderDate = DateTime.Parse(dtpDrawOrderDate.Text);
            if (txtDrawPerson.Tag != null)
            {
                DrawOrder.DrawPerson = txtDrawPerson.Tag.ToString();
            }
            if (txtEmitPerson.Tag != null)
            {
                DrawOrder.EmitPerson = txtEmitPerson.Tag.ToString();
            }
            if (txtOutStorage.Tag != null)
            {
                DrawOrder.OutStorage = txtOutStorage.Tag.ToString();
            }

            DrawOrder.Remark = txtRemark.Text;

            DrawOrder.CreateGuid = txtCreateGuid.Tag.ToString();
            DrawOrder.CreateDate = DateTime.Now;
            DrawOrder.CheckGuid  = "";
            DrawOrder.CheckDate  = DateTime.Parse("1900-01-01");



            List <DrawOrderDetail> list            = new List <DrawOrderDetail>();
            DrawOrderDetail        DrawOrderDetail = new DrawOrderDetail();

            for (int i = 0; i < gridView1.RowCount; i++)
            {
                DataRowView dr = (DataRowView)(gridView1.GetRow(i));

                DrawOrderDetail = new DrawOrderDetail();
                DrawOrderDetail.DrawOrderGuid = txtDrawOrderGuid.Text;
                DrawOrderDetail.MaterialGuID  = dr["MaterialGuID"].ToString();
                if (dr["ConsumeSum"].ToString().Trim() != "")
                {
                    DrawOrderDetail.ConsumeSum = decimal.Parse(dr["ConsumeSum"].ToString());
                }
                else
                {
                    DrawOrderDetail.ConsumeSum = 0;
                }

                if (dr["MaterialSum"].ToString().Trim() != "")
                {
                    DrawOrderDetail.MaterialSum = decimal.Parse(dr["MaterialSum"].ToString());
                }
                else
                {
                    DrawOrderDetail.MaterialSum = 0;
                }

                if (dr["ApplyMaterialSum"].ToString().Trim() != "")
                {
                    DrawOrderDetail.ApplyMaterialSum = decimal.Parse(dr["ApplyMaterialSum"].ToString());
                }
                else
                {
                    DrawOrderDetail.ApplyMaterialSum = 0;
                }
                DrawOrderDetail.SortID = i;
                list.Add(DrawOrderDetail);
            }



            //保存
            DrawOrderManage.SaveBill(DrawOrder, list);

            tsbCheck.Enabled   = true;
            tsbUnCheck.Enabled = false;

            SetRight();

            //写日志
            SysLog.AddOperateLog(SysParams.UserName, "领料单保存", "保存", SysParams.UserName + "用户保存领料单,唯一号:" + txtDrawOrderGuid.Text + ",领料单单号:" + txtDrawOrderID.Text);


            //用于打印
            DataTable dtl3 = base.GetDataTable((DataView)gridView1.DataSource);

            ds.Tables.Clear();
            ds.Tables.Add(dtl3.Copy());
            ds.Tables[0].TableName = "DrawOrderDetail";


            this.Tag = "edit";

            //保存时才出现保存成功提示,审核时,先保存数据后再审核
            if (SaveType == 1)
            {
                this.ShowMessage("保存成功");
            }

            frmDrawOrder.frmdraworder.LoadData();

            //正确则返回
            return(true);
        }