Exemplo n.º 1
0
 private void SetSelectedItem(Dealer selected_item = null)
 {
     if (selected_item != null)
     {
         foreach (DataGridViewRow row in this.dgvDealer.Rows)
         {
             if (((Dealer)row.Tag).id == selected_item.id)
             {
                 row.Cells[1].Selected = true;
                 Console.WriteLine(row.Cells[1].Value.ToString());
                 break;
             }
         }
     }
     else
     {
         foreach (DataGridViewRow row in this.dgvDealer.Rows)
         {
             if (string.CompareOrdinal(this.selected_dealer_code, ((Dealer)row.Tag).dealer) <= 0)
             {
                 row.Cells[1].Selected = true;
                 Console.WriteLine(row.Cells[1].Value.ToString());
                 break;
             }
         }
     }
 }
Exemplo n.º 2
0
        private void CreateDealer()
        {
            this.txtDummy.Focus();
            bool post_success = false;
            string err_msg = "";

            this.FormProcessing();
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                string json_data = "{\"dealer\":\"" + this.txtDealer.Texts.cleanString() + "\",";
                json_data += "\"prenam\":\"" + this.txtPrenam.Texts.cleanString() + "\",";
                json_data += "\"compnam\":\"" + this.txtCompnam.Texts.cleanString() + "\",";
                json_data += "\"addr01\":\"" + this.txtAddr01.Texts.cleanString() + "\",";
                json_data += "\"addr02\":\"" + this.txtAddr02.Texts.cleanString() + "\",";
                json_data += "\"addr03\":\"" + this.txtAddr03.Texts.cleanString() + "\",";
                json_data += "\"zipcod\":\"" + this.txtZipcod.Texts.cleanString() + "\",";
                json_data += "\"telnum\":\"" + this.txtTelnum.Texts.cleanString() + "\",";
                json_data += "\"faxnum\":\"" + this.txtFaxnum.Texts.cleanString() + "\",";
                json_data += "\"contact\":\"" + this.txtContact.Texts.cleanString() + "\",";
                json_data += "\"position\":\"" + this.txtPosition.Texts.cleanString() + "\",";
                json_data += "\"busides\":\"" + this.txtBusides.Texts.cleanString() + "\",";
                json_data += "\"area\":\"" + this.txtArea.Texts.cleanString() + "\",";
                json_data += "\"remark\":\"" + this.txtRemark.Texts.cleanString() + "\",";
                json_data += "\"users_name\":\"" + this.G.loged_in_user_name + "\"}";

                CRUDResult post = ApiActions.POST(PreferenceForm.API_MAIN_URL() + "dealer/create_new", json_data);
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(post.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    post_success = true;
                    this.dealer = sr.dealer[0];
                    this.serial = sr.serial;
                    this.d_msg = sr.d_msg;
                }
                else
                {
                    post_success = false;
                    err_msg = sr.message;
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (post_success)
                {
                    this.GetDealerIdList();
                    this.FillForm();
                    this.FormRead();
                }
                else
                {
                    this.FormAdd();
                    MessageAlert.Show(err_msg, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                    this.txtDealer.Focus();
                }
            };
            worker.RunWorkerAsync();
        }
Exemplo n.º 3
0
 private void returnSelectedResult()
 {
     this.dealer = (Dealer)this.dgvDealer.Rows[this.dgvDealer.CurrentCell.RowIndex].Tag;
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Exemplo n.º 4
0
        private void GetDealerByID(int id)
        {
            bool get_success = false;

            this.FormProcessing();
            BackgroundWorker worker = new BackgroundWorker();
            worker.DoWork += delegate
            {
                CRUDResult get = ApiActions.GET(PreferenceForm.API_MAIN_URL() + "dealer/get_with_id&id=" + id.ToString());
                ServerResult sr = JsonConvert.DeserializeObject<ServerResult>(get.data);

                if (sr.result == ServerResult.SERVER_RESULT_SUCCESS)
                {
                    if (sr.dealer.Count > 0)
                    {
                        this.dealer = sr.dealer[0];
                        get_success = true;

                        if (sr.serial.Count > 0)
                        {
                            this.serial = sr.serial;
                        }
                        else
                        {
                            this.serial = new List<Serial>();
                        }

                        this.d_msg = sr.d_msg;
                    }
                    else
                    {
                        get_success = false;
                        MessageAlert.Show("There's no data", "", MessageAlertButtons.OK, MessageAlertIcons.INFORMATION);
                    }
                }
            };
            worker.RunWorkerCompleted += delegate
            {
                if (get_success)
                {
                    this.FillForm();
                    this.FormRead();
                }
                else
                {
                    MessageAlert.Show(StringResource.DATA_NOT_FOUND, "Error", MessageAlertButtons.OK, MessageAlertIcons.ERROR);
                }
            };
            worker.RunWorkerAsync();
        }