Ejemplo n.º 1
0
        private void txtquotelinkman_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtquotesuppliercode.Text) == true)
            {
                MessageBox.Show("请先选择供应商,再操作。");
                return;
            }
            if (txtquotesuppliercode.Tag == null)
            {
                return;
            }
            string companycode = string.Empty;

            companycode = txtquotesuppliercode.Tag.ToString();
            UIForms.FormSelectCustomer form = new UIForms.FormSelectCustomer(companycode);
            form.StartPosition = FormStartPosition.CenterParent;
            DialogResult result = form.ShowDialog();

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FishEntity.CustomerEntity customer = form.SelectedCustomer;
                if (customer != null)
                {
                    txtquotelinkman.Text = customer.name;
                    txtquotelinkman.Tag  = customer.code;
                }
            }
        }
Ejemplo n.º 2
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex < 0 || e.RowIndex < 0)
     {
         return;
     }
     if (dataGridView1.Columns[e.ColumnIndex].Name.Equals("yifang", 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["yifang"].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("linkman", StringComparison.OrdinalIgnoreCase) == true)
     {
         if (dataGridView1.Rows[e.RowIndex].Cells["yifang"].Value == null || string.IsNullOrEmpty(dataGridView1.Rows[e.RowIndex].Cells["yifang"].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["linkman"].Value = customer.name;
                 //dataGridView1.Rows[e.RowIndex].Cells["customercode"].Value = customer.code;
                 //dataGridView1.Rows[e.RowIndex].Cells["customerid"].Value = customer.id;
             }
         }
     }
 }
Ejemplo n.º 3
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("同步失败");
                }
            }
        }