Пример #1
0
 /// <summary>
 /// get table record
 /// <summary>
 /// <param name=out emsg>return error message</param>
 ///<returns>get a record detail of acccurrencylist</returns>
 public modAccCurrencyList GetOwnerItem(out string emsg)
 {
     try
     {
         //Execute a query to read the categories
         string sql = "select currency,exchange_rate,owner_flag,update_user,update_time from acc_currency_list where owner_flag=1";
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             if (rdr.Read())
             {
                 modAccCurrencyList model = new modAccCurrencyList();
                 model.Currency     = dalUtility.ConvertToString(rdr["currency"]);
                 model.ExchangeRate = dalUtility.ConvertToDecimal(rdr["exchange_rate"]);
                 model.OwnerFlag    = dalUtility.ConvertToInt(rdr["owner_flag"]);
                 model.UpdateUser   = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime   = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 emsg = null;
                 return(model);
             }
             else
             {
                 emsg = "Error on read data";
                 return(null);
             }
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Пример #2
0
 /// <summary>
 /// get all acccurrencylist
 /// <summary>
 /// <param name=out emsg>return error message</param>
 ///<returns>details of all acccurrencylist</returns>
 public BindingCollection <modAccCurrencyList> GetIList(out string emsg)
 {
     try
     {
         BindingCollection <modAccCurrencyList> modellist = new BindingCollection <modAccCurrencyList>();
         //Execute a query to read the categories
         string sql = "select currency,exchange_rate,owner_flag,update_user,update_time from acc_currency_list order by owner_flag desc,currency";
         using (SqlDataReader rdr = SqlHelper.ExecuteReader(sql))
         {
             while (rdr.Read())
             {
                 modAccCurrencyList model = new modAccCurrencyList();
                 model.Currency     = dalUtility.ConvertToString(rdr["currency"]);
                 model.ExchangeRate = dalUtility.ConvertToDecimal(rdr["exchange_rate"]);
                 model.OwnerFlag    = dalUtility.ConvertToInt(rdr["owner_flag"]);
                 model.UpdateUser   = dalUtility.ConvertToString(rdr["update_user"]);
                 model.UpdateTime   = dalUtility.ConvertToDateTime(rdr["update_time"]);
                 modellist.Add(model);
             }
         }
         emsg = null;
         return(modellist);
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(null);
     }
 }
Пример #3
0
 protected override bool Save()
 {
     try
     {
         this.Cursor = Cursors.WaitCursor;
         if (string.IsNullOrEmpty(txtCurrency.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("Currency") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtCurrency.Focus();
             return(false);
         }
         if (string.IsNullOrEmpty(txtExchangeRate.Text.Trim()))
         {
             MessageBox.Show(clsTranslate.TranslateString("Exchange rate") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtCurrency.Focus();
             return(false);
         }
         if (!Util.IsNumeric(txtExchangeRate.Text))
         {
             MessageBox.Show(clsTranslate.TranslateString("Exchange rate") + clsTranslate.TranslateString(" must be numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             txtExchangeRate.Focus();
             return(false);
         }
         modAccCurrencyList mod = new modAccCurrencyList(txtCurrency.Text.Trim(), Convert.ToDecimal(txtExchangeRate.Text), 0, Util.UserId, DateTime.Now);
         bool ret = false;
         if (_status == 1)
         {
             ret = _dal.Insert(mod, out Util.emsg);
         }
         else if (_status == 2)
         {
             ret = _dal.Update(txtCurrency.Text, mod, out Util.emsg);
         }
         if (ret)
         {
             Util.ChangeStatus(this, true);
             DBGrid.Enabled = true;
             LoadData();
             FindText = mod.Currency;
             Find();
         }
         return(ret);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
         return(false);
     }
     finally
     {
         this.Cursor = Cursors.Default;
     }
 }
Пример #4
0
 protected override void Find()
 {
     for (int i = 0; i < DBGrid.Rows.Count; i++)
     {
         modAccCurrencyList mod = (modAccCurrencyList)DBGrid.Rows[i].DataBoundItem;
         if (mod.Currency.CompareTo(FindText) == 0)
         {
             DBGrid.CurrentCell = DBGrid.Rows[i].Cells[0];
             DBGrid_SelectionChanged(null, null);
             return;
         }
     }
 }
Пример #5
0
 private void DBGrid_SelectionChanged(object sender, EventArgs e)
 {
     if (DBGrid.CurrentRow != null)
     {
         modAccCurrencyList mod = (modAccCurrencyList)DBGrid.CurrentRow.DataBoundItem;
         txtCurrency.Text     = mod.Currency;
         txtExchangeRate.Text = mod.ExchangeRate.ToString();
         FindText             = mod.Currency;
         if (txtExchangeRate.Text.Trim() == "1")
         {
             EditVisible = false;
             DelVisible  = false;
         }
         else
         {
             EditVisible = true;
             DelVisible  = true;
         }
     }
 }
Пример #6
0
        public static decimal GetExchangeRate(string accountno)
        {
            dalAccBankAccount dal = new dalAccBankAccount();
            modAccBankAccount mod = dal.GetItem(accountno, out Util.emsg);

            if (mod != null)
            {
                dalAccCurrencyList dal2 = new dalAccCurrencyList();
                modAccCurrencyList mod2 = dal2.GetItem(mod.Currency, out Util.emsg);
                if (mod2 != null)
                {
                    return(mod2.ExchangeRate);
                }
                else
                {
                    return(1);
                }
            }
            else
            {
                return(1);
            }
        }
Пример #7
0
 /// <summary>
 /// update a acccurrencylist
 /// <summary>
 /// <param name=currency>currency</param>
 /// <param name=mod>model object of acccurrencylist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Update(string currency, modAccCurrencyList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("update acc_currency_list set exchange_rate={0},owner_flag={1},update_user='******',update_time=getdate() where currency='{3}'", mod.ExchangeRate, mod.OwnerFlag, mod.UpdateUser, currency);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }
Пример #8
0
 /// <summary>
 /// insert a acccurrencylist
 /// <summary>
 /// <param name=mod>model object of acccurrencylist</param>
 /// <param name=out emsg>return error message</param>
 /// <returns>true/false</returns>
 public bool Insert(modAccCurrencyList mod, out string emsg)
 {
     try
     {
         string sql = string.Format("insert into acc_currency_list(currency,exchange_rate,owner_flag,update_user,update_time)values('{0}',{1},{2},'{3}',getdate())", mod.Currency, mod.ExchangeRate, mod.OwnerFlag, mod.UpdateUser);
         int    i   = SqlHelper.ExecuteNonQuery(sql);
         if (i > 0)
         {
             emsg = null;
             return(true);
         }
         else
         {
             emsg = "Unknown error when ExecuteNonQuery!";
             return(false);
         }
     }
     catch (Exception ex)
     {
         emsg = dalUtility.ErrorMessage(ex.Message);
         return(false);
     }
 }
Пример #9
0
        private void Login()
        {
            if (txtSystemTime.Text.Trim() != txtServerTime.Text.Trim())
            {
                DateTime dt1 = DateTime.Parse(txtSystemTime.Text);
                DateTime dt2 = DateTime.Parse(txtServerTime.Text);
                TimeSpan ts  = new TimeSpan(dt1.Ticks - dt2.Ticks);
                if (Math.Abs(ts.Days) > 1 || Math.Abs(ts.Minutes) > 2 || Math.Abs(ts.Hours) > 1 || Math.Abs(ts.Days) > 1)
                {
                    MessageBox.Show(clsTranslate.TranslateString("local time must equal to server time,please adjust your system time first!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtSystemTime.Focus();
                    return;
                }
            }
            if (cboPeriodList.Items.Count == 0)
            {
                btnNew_Click(null, null);
                return;
            }
            if (txtUserId.Text.Trim().Length == 0)
            {
                MessageBox.Show("User Id can not be null!");
                txtUserId.Focus();
                return;
            }
            if (txtPwd.Text.Trim().Length == 0)
            {
                MessageBox.Show("Password can not be null!");
                txtPwd.Focus();
                return;
            }

            this.Cursor = Cursors.WaitCursor;
            string      userid = txtUserId.Text.Trim().ToString();
            string      strPwd = Util.Encrypt(txtPwd.Text.Trim().ToString(), Util.PWD_MASK);
            dalUserList dal    = new dalUserList();
            bool        ret    = dal.Login(userid, strPwd, out Util.emsg);

            if (ret)
            {
                modUserList mod = dal.GetItem(userid);
                Util.UserId   = mod.UserId;
                Util.UserName = mod.UserName;
                Util.RoleId   = mod.RoleId;
                dalRoleList role    = new dalRoleList();
                modRoleList modrole = role.GetItem(mod.RoleId, out Util.emsg);
                Util.RoleDesc   = modrole.RoleDesc;
                Util.UserStatus = mod.Status;
                ini.IniWriteValue("login", "userid", userid);

                dalAccCurrencyList dalcur = new dalAccCurrencyList();
                modAccCurrencyList modcur = dalcur.GetOwnerItem(out Util.emsg);
                Util.Currency = modcur.Currency;
                dalLogLoginHost bllhost = new dalLogLoginHost();
                modLogLoginHost modhost = new modLogLoginHost();
                modhost.HostName = Environment.MachineName;
                Util.modperiod   = (modAccPeriodList)cboPeriodList.SelectedItem;
                clsLxms.CheckSoftwareRegister();
                if (Util.SOFT_REGISTER)
                {
                    modhost.RegisterCode = Util.REGISTER_CODE;
                }
                else
                {
                    modhost.RegisterCode = string.Empty;
                    if (cboPeriodList.Items.Count >= 7)
                    {
                        frmSoftRegister frm = new frmSoftRegister();
                        if (frm.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                    }
                }
                modhost.HostCode   = Util.HOST_CODE;
                modhost.UpdateUser = Util.UserId;
                if (bllhost.Exists(modhost.HostName, out Util.emsg))
                {
                    bllhost.Update(modhost.HostName, modhost, out Util.emsg);
                }
                else
                {
                    bllhost.Insert(modhost, out Util.emsg);
                }

                this.DialogResult = DialogResult.OK;
                this.Cursor       = Cursors.Default;
                return;
            }
            else
            {
                //this.DialogResult = DialogResult.Cancel;
                this.Cursor = Cursors.Default;
                MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }
Пример #10
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                DBGrid.EndEdit();
                if (DBGrid.RowCount == 0)
                {
                    MessageBox.Show("没有明细数据", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    if (DBGrid.Rows[i].Cells[0].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[0].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Product id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    if (DBGrid.Rows[i].Cells[4].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[4].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (!Util.IsNumeric(DBGrid.Rows[i].Cells[4].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (Convert.ToDecimal(DBGrid.Rows[i].Cells[4].Value.ToString()) <= 0)
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" must > 0!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }

                    if (DBGrid.Rows[i].Cells[5].Value == null || string.IsNullOrEmpty(DBGrid.Rows[i].Cells[5].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Price") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    else if (!Util.IsNumeric(DBGrid.Rows[i].Cells[5].Value.ToString()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Price") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                }

                modSalesShipment mod = new modSalesShipment();
                mod.ShipId   = _dal.GetNewId(DateTime.Today);
                mod.ShipDate = DateTime.Today;
                mod.ShipType = "收营单";
                //mod.No = txtNo.Text.Trim();
                mod.AdFlag = 1;
                dalCustomerList dalcust = new dalCustomerList();
                //mod.CustOrderNo = txtCustOrderNo.Text.Trim();
                mod.CustName = "散客";
                mod.CustId   = clsLxms.GetDefaultCustId();

                mod.PayMethod = "现金";
                mod.SalesMan  = Util.UserId;
                mod.OtherMny  = 0;
                mod.KillMny   = 0;
                mod.Currency  = Util.Currency;
                dalAccCurrencyList dalcur = new dalAccCurrencyList();
                modAccCurrencyList modcur = dalcur.GetItem(mod.Currency, out Util.emsg);
                mod.ExchangeRate  = modcur.ExchangeRate;
                mod.DetailSum     = decimal.Parse(txtAmount.Text);
                mod.UpdateUser    = Util.UserId;
                mod.Status        = 0;
                mod.ReceiveStatus = 1;
                mod.AccountNo     = "现金";

                mod.MakeDate      = DateTime.Today;
                mod.ReceiveDate   = DateTime.Today.ToString("yyyy-MM-dd");
                mod.InvoiceStatus = 0;
                mod.InvoiceMny    = 0;
                string detaillist             = string.Empty;
                dalCustomerOrderList dalorder = new dalCustomerOrderList();
                BindingCollection <modSalesShipmentDetail> list = new BindingCollection <modSalesShipmentDetail>();
                for (int i = 0; i < DBGrid.RowCount; i++)
                {
                    modSalesShipmentDetail modd = new modSalesShipmentDetail();
                    modd.Seq         = i + 1;
                    modd.ProductId   = DBGrid.Rows[i].Cells[0].Value.ToString();
                    modd.ProductName = DBGrid.Rows[i].Cells[1].Value.ToString();
                    modd.Specify     = DBGrid.Rows[i].Cells[8].Value.ToString();
                    modd.UnitNo      = DBGrid.Rows[i].Cells[3].Value.ToString();
                    modd.Size        = 1;
                    modd.Qty         = Convert.ToDecimal(DBGrid.Rows[i].Cells[4].Value.ToString());
                    modd.Price       = Convert.ToDecimal(DBGrid.Rows[i].Cells[5].Value.ToString());
                    modd.SalesManMny = 0;
                    modd.WarehouseId = clsLxms.GetDefaultWarehouseId();

                    list.Add(modd);
                }
                bool ret = _dal.Save("ADD", mod, list, out Util.emsg);
                if (ret)
                {
                    this.DialogResult = DialogResult.OK;
                    LoadHistory();
                    DBGrid.Rows.Clear();
                    txtQty.Text    = "0";
                    txtAmount.Text = "0";
                    btnPreview_Click(null, null);
                    txtProduct.Focus();
                }
                else
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Пример #11
0
        private void toolSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                if (dtpFormDate.Value < Util.modperiod.StartDate)
                {
                    MessageBox.Show("该日期的数据已锁定,不能更新数据!", clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    dtpFormDate.Focus();
                    return;
                }
                if (cboDesignType.SelectedValue == null || string.IsNullOrEmpty(cboDesignType.SelectedValue.ToString()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Form Type") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    cboDesignType.Focus();
                    return;
                }
                if (cboReceiveStatus.SelectedValue == null || string.IsNullOrEmpty(cboReceiveStatus.SelectedValue.ToString()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Receive Status") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    cboReceiveStatus.Focus();
                    return;
                }
                if (cboInvoiceStatus.SelectedValue == null || string.IsNullOrEmpty(cboInvoiceStatus.SelectedValue.ToString()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Invoice Status") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    cboInvoiceStatus.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtQty.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtQty.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtQty.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Qty") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtQty.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtMny.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtMny.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtMny.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtMny.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtSalesManMny.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Sales Man Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSalesManMny.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtSalesManMny.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Sales Man Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSalesManMny.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtInvoiceMny.Text.Trim()))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Invoice Mny") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtInvoiceMny.Focus();
                    return;
                }
                else if (!Util.IsNumeric(txtInvoiceMny.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Invoice Mny") + clsTranslate.TranslateString(" must be a numeric!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtInvoiceMny.Focus();
                    return;
                }
                if (cboInvoiceStatus.SelectedIndex == 2)
                {
                    if (Convert.ToDecimal(txtInvoiceMny.Text) == 0)
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Invoice Mny") + clsTranslate.TranslateString(" must >0 !"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtInvoiceMny.Focus();
                        return;
                    }
                    if (string.IsNullOrEmpty(txtInvoiceNo.Text.Trim()))
                    {
                        MessageBox.Show(clsTranslate.TranslateString("Invoice No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtInvoiceNo.Focus();
                        return;
                    }
                }
                if (txtCustName.Tag == null)
                {
                    MessageBox.Show(clsTranslate.TranslateString("Cust Id") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustName.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtCustName.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Cust Name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustName.Focus();
                    return;
                }
                if (clsLxms.GetParameterValue("NEED_SHIP_NO").CompareTo("T") == 0 && string.IsNullOrEmpty(txtNo.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtNo.Focus();
                    return;
                }
                if (clsLxms.GetParameterValue("NEED_CUST_ORDER_NO").CompareTo("T") == 0 && string.IsNullOrEmpty(txtCustOrderNo.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Cust Order No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtCustOrderNo.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtSalesMan.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Sales Man") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtSalesMan.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtUnitNo.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Unit No") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtUnitNo.Focus();
                    return;
                }
                if (string.IsNullOrEmpty(txtProductName.Text))
                {
                    MessageBox.Show(clsTranslate.TranslateString("Product Name") + clsTranslate.TranslateString(" can not be null!"), clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    txtProductName.Focus();
                    return;
                }
                if (!string.IsNullOrEmpty(txtCustOrderNo.Text.Trim()))
                {
                    dalCustomerOrderList dalorder = new dalCustomerOrderList();
                    if (!dalorder.Exists(txtCustName.Tag.ToString(), txtCustOrderNo.Text.Trim(), out Util.emsg))
                    {
                        if (MessageBox.Show("无法找到对应的客户订单号,您要继续保存吗?", clsTranslate.TranslateString("Confirm"), MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            return;
                        }
                    }
                }
                modSalesDesignForm mod = new modSalesDesignForm();
                mod.Id          = Convert.ToInt32(txtId.Text);
                mod.FormDate    = dtpFormDate.Value;
                mod.FormType    = cboDesignType.SelectedValue.ToString();
                mod.No          = txtNo.Text.Trim();
                mod.AdFlag      = cboDesignType.SelectedValue.ToString().IndexOf("退货") > 0 ? -1 : 1;
                mod.CustOrderNo = txtCustOrderNo.Text.Trim();
                mod.CustId      = txtCustName.Tag.ToString();
                mod.CustName    = txtCustName.Text.Trim();
                mod.PayMethod   = txtPayMethod.Text.Trim();
                mod.SalesMan    = txtSalesMan.Text.Trim();
                mod.ProductName = txtProductName.Text.Trim();
                mod.Remark      = txtRemark.Text.Trim();
                mod.Currency    = txtCurrency.Text.Trim();
                dalAccCurrencyList dalcur = new dalAccCurrencyList();
                modAccCurrencyList modcur = dalcur.GetItem(txtCurrency.Text.Trim(), out Util.emsg);
                mod.ExchangeRate  = modcur.ExchangeRate;
                mod.UnitNo        = txtUnitNo.Text.Trim();
                mod.Qty           = Convert.ToDecimal(txtQty.Text);
                mod.Mny           = Convert.ToDecimal(txtMny.Text);
                mod.SalesManMny   = Convert.ToDecimal(txtSalesManMny.Text);
                mod.UpdateUser    = Util.UserId;
                mod.Status        = 0;
                mod.ReceiveStatus = cboReceiveStatus.SelectedIndex;
                mod.AccountNo     = cboAccountNo.SelectedValue == null ? string.Empty : cboAccountNo.SelectedValue.ToString();
                mod.ReceiveDate   = txtReceiveDate.Text.Trim();
                mod.InvoiceStatus = cboInvoiceStatus.SelectedIndex;
                mod.InvoiceMny    = Convert.ToDecimal(txtInvoiceMny.Text);
                mod.InvoiceNo     = txtInvoiceNo.Text.Trim();
                string detaillist = string.Empty;

                bool ret = false;
                if (_action == "NEW" || _action == "ADD")
                {
                    ret = _dal.Insert(mod, out Util.emsg);
                }
                else
                {
                    ret = _dal.Update(mod.Id, mod, out Util.emsg);
                }
                if (ret)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show(Util.emsg, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, clsTranslate.TranslateString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }