Exemple #1
0
        private void txtSupplier_Click(object sender, EventArgs e)
        {
            FormCompanyList form = new FormCompanyList();

            form.StartPosition = FormStartPosition.CenterParent;
            if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            if (form.SelectCompany == null)
            {
                return;
            }
            txtSupplier.Text = form.SelectCompany.fullname;
            txtSupplier.Tag  = form.SelectCompany.code;
        }
Exemple #2
0
        protected void SelectCompany(TextBox txt)
        {
            FormCompanyList form = new FormCompanyList();

            form.StartPosition = FormStartPosition.CenterParent;
            if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            if (form.SelectCompany == null)
            {
                return;
            }
            txt.Tag  = form.SelectCompany.code;
            txt.Text = form.SelectCompany.shortname;
        }
Exemple #3
0
        private void txtCompanyName_Click(object sender, EventArgs e)
        {
            FormCompanyList form = new FormCompanyList();

            form.StartPosition = FormStartPosition.CenterParent;
            if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            if (form.SelectCompany == null)
            {
                return;
            }

            SetCompanyData(form.SelectCompany);
        }
        private void txtCustomer_Click(object sender, EventArgs e)
        {
            FormCompanyList form = new FormCompanyList();

            form.StartPosition = FormStartPosition.CenterParent;
            if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            if (form.SelectCompany == null)
            {
                return;
            }
            txtCustomer.Text = form.SelectCompany.fullname;
            txtCustomer.Tag  = form.SelectCompany.code;

            FishBll.Bll.CustomerBll          bll  = new FishBll.Bll.CustomerBll();
            List <FishEntity.CustomerEntity> mans = bll.GetCustomerOfCompany(form.SelectCompany.id);

            if (mans == null)
            {
                mans = new List <FishEntity.CustomerEntity>();
            }
            cmbTheperson.SelectedValue = form.SelectCompany.salesman;
            cmbTheperson.Tag           = form.SelectCompany.salesmancode;


            panel2.Controls.Clear();
            foreach (FishEntity.CustomerEntity item in mans)
            {
                CheckBox chk = new CheckBox();
                chk.Text     = item.name.Trim();
                chk.Tag      = item;
                chk.AutoSize = true;
                chk.Checked  = false;
                chk.Dock     = DockStyle.Left;
                panel2.Controls.Add(chk);
            }
        }
Exemple #5
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }
            if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("company", StringComparison.OrdinalIgnoreCase) == true)
            {
                FormCompanyList form = new FormCompanyList();
                form.StartPosition = FormStartPosition.CenterParent;
                if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                if (form.SelectCompany == null)
                {
                    return;
                }
                dataGridView1.Rows[e.RowIndex].Cells["companyid"].Value    = form.SelectCompany.id;
                dataGridView1.Rows[e.RowIndex].Cells["companycode"].Value  = form.SelectCompany.code;
                dataGridView1.Rows[e.RowIndex].Cells["company"].Value      = form.SelectCompany.fullname;
                dataGridView1.Rows[e.RowIndex].Cells["customerid"].Value   = string.Empty;
                dataGridView1.Rows[e.RowIndex].Cells["customercode"].Value = string.Empty;
                dataGridView1.Rows[e.RowIndex].Cells["customer"].Value     = string.Empty;
            }
            if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("customer", StringComparison.OrdinalIgnoreCase) == true)
            {
                if (dataGridView1.Rows[e.RowIndex].Cells["company"].Value == null || string.IsNullOrEmpty(dataGridView1.Rows[e.RowIndex].Cells["company"].Value.ToString()) == true)
                {
                    MessageBox.Show("请先选择单位,再操作。");
                    return;
                }
                int companyId = 0;
                int.TryParse(dataGridView1.Rows[e.RowIndex].Cells["companyid"].Value.ToString(), out companyId);
                UIForms.FormSelectCustomer form = new UIForms.FormSelectCustomer(companyId);
                form.StartPosition = FormStartPosition.CenterParent;
                DialogResult result = form.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    FishEntity.CustomerEntity customer = form.SelectedCustomer;
                    if (customer != null)
                    {
                        dataGridView1.Rows[e.RowIndex].Cells["customer"].Value     = customer.name;
                        dataGridView1.Rows[e.RowIndex].Cells["customercode"].Value = customer.code;
                        dataGridView1.Rows[e.RowIndex].Cells["customerid"].Value   = customer.id;
                    }
                }
            }
            if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("btnasync", StringComparison.OrdinalIgnoreCase) == true)
            {
                //
                if (Check() == false)
                {
                    return;
                }

                decimal latestprice = 0;
                decimal latedollars = 0;
                decimal latermb     = 0;
                decimal lateweight  = 0;
                string  latedate;
                decimal laterate;
                string  companycode;
                string  companyname;
                string  customercode;
                string  customername;
                int     latequantity = 0;

                DateTime        latestTime = DateTime.MinValue;
                DataGridViewRow row        = dataGridView1.Rows[e.RowIndex];
                int             id         = 0;
                object          obj        = row.Cells["id"].EditedFormattedValue;
                if (obj == null)
                {
                    id = 0;
                }
                else
                {
                    int.TryParse(obj.ToString(), out id);
                }

                decimal temp2;
                decimal.TryParse(row.Cells["dollars"].EditedFormattedValue.ToString(), out temp2);
                latedollars = temp2;

                decimal.TryParse(row.Cells["rmb"].EditedFormattedValue.ToString(), out temp2);
                latermb = temp2;

                companycode = row.Cells["companycode"].Value == null ? "" : row.Cells["companycode"].Value.ToString();
                companyname = row.Cells["company"].Value == null ? "" : row.Cells["company"].Value.ToString();

                customercode = row.Cells["customercode"].Value == null ? "" : row.Cells["customercode"].Value.ToString();;
                customername = row.Cells["customer"].Value == null ? "" : row.Cells["customer"].Value.ToString();

                decimal.TryParse(row.Cells["weight"].EditedFormattedValue == null ? "0" : row.Cells["weight"].EditedFormattedValue.ToString(), out temp2);
                lateweight = temp2;

                int quantity = 0;
                int.TryParse(row.Cells["quantity"].EditedFormattedValue == null ? "0" : row.Cells["quantity"].EditedFormattedValue.ToString(), out quantity);
                latequantity = quantity;

                DateTime quotedate;
                DateTime.TryParse(row.Cells["date"].EditedFormattedValue.ToString(), out quotedate);
                DateTime quotetime;
                DateTime.TryParse(row.Cells["time"].EditedFormattedValue.ToString(), out quotetime);
                latedate = quotedate.ToString("yyyy/MM/dd") + " " + quotetime.ToString("HH:mm:ss");

                decimal.TryParse(row.Cells["rate"].EditedFormattedValue == null ? "0" : row.Cells["rate"].EditedFormattedValue.ToString(), out temp2);
                laterate = temp2;

                bool isok = _bll.UpdateLatestQuote(_productId, latedollars, latermb, companycode, companyname, customercode, customername, latedate, lateweight, latequantity);
                if (isok)
                {
                    OnRefreshData(_productId, latestprice, latedollars, latermb,
                                  laterate, latestTime.ToString("yyyy/MM/dd HH:mm:ss"), companyname, customername, lateweight, latequantity);
                    MessageBox.Show("同步成功");
                }
                else
                {
                    MessageBox.Show("同步失败");
                }
            }
        }