예제 #1
0
        //

        private void submit_btn_Click(object sender, EventArgs e)
        {
            submit_clicked = true;

            Zednadebi        shetana_zed   = null;
            AngarishFaqtura  shetana_af    = null;
            List <Remainder> zed_prod_list = new List <Remainder>();

            if (supplier_chooser.SelectedIndex >= 0 && supplier_chooser.SelectedIndex < all_suppliers.Length)
            {
                if ("" == zed_ident_code_txt.Text)
                {
                    MessageBox.Show("ზედნადების საიდენტიფიკაციო კოდი არ არის მითითებული!");
                    return;
                }
                shetana_zed = new Zednadebi(zed_ident_code_txt.Text, zed_dro_datechooser.Value, add_rem_af_seria.Text, add_rem_af_nomeri.Text, DataProvider.OperationType.Buy, all_suppliers[supplier_chooser.SelectedIndex].saidentifikacio_kodi, DataProvider.PaymentType.Nagdi);
            }
            else
            {
                MessageBox.Show("მომწოდებელი არ არის მითითებული!");
                return;
            }

            foreach (DataGridViewRow nextRow in add_remainders_list.Rows)
            {
                if (!nextRow.IsNewRow)
                {
                    Remainder nextRemS1 = new Remainder();

                    if (null == nextRow.Cells[add_rem_barcode_col.Index].Value |
                        null == nextRow.Cells[add_rem_capacity_col.Index].Value |
                        null == nextRow.Cells[add_rem_count_type_col.Index].Value |
                        null == nextRow.Cells[add_rem_storeid_col.Index].Value |
                        0 >= Convert.ToInt32((nextRow.Cells[add_rem_storeid_col.Index].Value ?? 0).ToString()) |
                        null == nextRow.Cells[add_rem_piece_count_col.Index].Value |
                        null == nextRow.Cells[add_rem_piece_price_col.Index].Value |
                        0 > ParseDecimal((nextRow.Cells[add_rem_sell_price_col.Index].Value ?? 0).ToString()))
                    {
                        HighlightNonCompleteFields(nextRow);

                        status_bar_lbl.Text = "გთხოვთ შეავსოთ აუცილებელი ველები!";
                        return;
                    }
                    else
                    {
                        string  nbarcode     = nextRow.Cells[add_rem_barcode_col.Index].Value.ToString();
                        string  nzedid       = zed_ident_code_txt.Text;
                        decimal ncapacity    = ParseDecimal(nextRow.Cells[add_rem_capacity_col.Index].Value.ToString());
                        decimal npiece_price = ParseDecimal(nextRow.Cells[add_rem_piece_price_col.Index].Value.ToString());

                        int     nstore_id    = 0;
                        decimal npiece_count = 0.0m;
                        decimal nsell_price  = 0.0m;

                        nstore_id    = Convert.ToInt32(nextRow.Cells[add_rem_storeid_col.Index].Value.ToString());
                        npiece_count = ParseDecimal(nextRow.Cells[add_rem_piece_count_col.Index].Value.ToString());
                        nsell_price  = ParseDecimal((nextRow.Cells[add_rem_sell_price_col.Index].Value ?? 0).ToString());


                        if ("ყუთები" == nextRow.Cells[add_rem_count_type_col.Index].Value.ToString())
                        {
                            npiece_count *= ncapacity;
                        }
                        else
                        {
                        }
                        nextRemS1.storehouse_id     = nstore_id;
                        nextRemS1.product_barcode   = nbarcode;
                        nextRemS1.supplier_ident    = all_suppliers[supplier_chooser.SelectedIndex].saidentifikacio_kodi;
                        nextRemS1.zednadebis_nomeri = nzedid;
                        nextRemS1.pack_capacity     = ncapacity;
                        nextRemS1.buy_price         = npiece_price;
                        nextRemS1.formal_buy_price  = npiece_price;
                        nextRemS1.sell_price        = nsell_price;
                        nextRemS1.formal_sell_price = nsell_price;
                        nextRemS1.initial_pieces    = npiece_count;
                        nextRemS1.remaining_pieces  = npiece_count;

                        if (npiece_count > 0)
                        {
                            zed_prod_list.Add(nextRemS1);
                        }
                    }
                }
                else
                {
                    //Last, unused row (IsNewRow)
                }
            }//foreach datagridviewrow

            if (!(zed_prod_list.Count > 0))
            {
                status_bar_lbl.Text = "პროდუქტების სიის გარეშე გაყიდვა არ მოხდება!";
                return;
            }

            PurchaseOrder shemotana_pur;

            if (using_af_ckb.Checked && "" != add_rem_af_seria.Text && "" != add_rem_af_nomeri.Text)
            {
                shetana_af    = new AngarishFaqtura(add_rem_af_seria.Text, add_rem_af_nomeri.Text, add_rem_af_date_chooser.Value, DataProvider.OperationType.Buy, all_suppliers[supplier_chooser.SelectedIndex].saidentifikacio_kodi);
                shemotana_pur = new PurchaseOrder(DateTime.Now, all_suppliers[supplier_chooser.SelectedIndex], shetana_zed, zed_prod_list.ToArray(), shetana_af);
            }
            else
            {
                shemotana_pur = new PurchaseOrder(DateTime.Now, all_suppliers[supplier_chooser.SelectedIndex], shetana_zed, zed_prod_list.ToArray(), null);
            }
            info trans_res = ProductInfo_Main_Form.conn.AddPurchaseOrder(shemotana_pur);

            MessageBox.Show(trans_res.errcode.ToString() + ":" + trans_res.details);
            //MessageBox.Show("TODO in DataProvider: SPROC RETVAL??? " + trans_res.errcode.ToString() + ":" + trans_res.details);
            if (501 == trans_res.errcode | 0 == trans_res.errcode)
            {
                MessageBox.Show("ზედნადები დამატებულია.");
                this.Close();
            }
            else
            {
                MessageBox.Show("მოხდა შეცდომა. ზედნადები არ დამატებულა! ");
            }
        }
예제 #2
0
        private void submit_btn_Click()
        {
            submit_clicked = true;

            Zednadebi        gayidva_zed   = null;
            AngarishFaqtura  gayidva_af    = null;
            List <Remainder> zed_prod_list = new List <Remainder>();

            DataProvider.PaymentType paying_method_now = DataProvider.PaymentType.Nagdi;
            if ("ნაღდი" == ckb_pay_method.Text)
            {
                paying_method_now = DataProvider.PaymentType.Nagdi;
            }
            else if ("კონსიგნაცია" == ckb_pay_method.Text)
            {
                paying_method_now = DataProvider.PaymentType.Konsignacia;
            }
            else if ("უნაღდო" == ckb_pay_method.Text)
            {
                paying_method_now = DataProvider.PaymentType.Unagdo;
            }

            if (buyer_chooser.SelectedIndex >= 0 && buyer_chooser.SelectedIndex < all_buyers.Length)
            {
                if ("" == zed_ident_code_txt.Text)
                {
                    MessageBox.Show("ზედნადების საიდენტიფიკაციო კოდი არ არის მითითებული!");
                    return;
                }
                gayidva_zed = new Zednadebi(zed_ident_code_txt.Text, zed_dro_datechooser.Value, add_rem_af_seria.Text, add_rem_af_nomeri.Text, DataProvider.OperationType.Sell, all_buyers[buyer_chooser.SelectedIndex].saidentifikacio_kodi, paying_method_now);
            }
            else
            {
                MessageBox.Show("მყიდველი არ არის მითითებული!");
                return;
            }

            zed_prod_list = GetAllEnteredRemainders();

            if (zed_prod_list.Count <= 0)
            {
                MessageBox.Show("ცარიელი ზედნადების გაყიდვა არაა დაშვებული!");
                return;
            }

            if (zed_prod_list.Count > 23)
            {
                MessageBox.Show("ზედნადების ფორმით 23–ზე მეტი პროდუქტის გაყიდვა არაა დაშვებული!");
                return;
            }

            SellOrder shemotana_SO;

            if (using_af_ckb.Checked && "" != add_rem_af_seria.Text && "" != add_rem_af_nomeri.Text)
            {
                gayidva_af   = new AngarishFaqtura(add_rem_af_seria.Text, add_rem_af_nomeri.Text, add_rem_af_date_chooser.Value, DataProvider.OperationType.Sell, all_buyers[buyer_chooser.SelectedIndex].saidentifikacio_kodi);
                shemotana_SO = new SellOrder(gayidva_zed.dro, true, paying_method_now, all_buyers[buyer_chooser.SelectedIndex], gayidva_zed, zed_prod_list.ToArray(), gayidva_af);
            }
            else
            {
                shemotana_SO = new SellOrder(gayidva_zed.dro, true, paying_method_now, all_buyers[buyer_chooser.SelectedIndex], gayidva_zed, zed_prod_list.ToArray(), null);
            }
            //this variable will be initialized by the AddSellOrder call, but not neccessery in this code because this SellOrder is Zednadebi (Invoice)
            int  SellOrderInsertID;
            info trans_res = ProductInfo_Main_Form.conn.AddSellOrder(shemotana_SO, out SellOrderInsertID);

            MessageBox.Show("TODO in DataProvider: SPROC RETVAL??? " + trans_res.errcode.ToString() + ":" + trans_res.details);
            if (501 == trans_res.errcode | 0 == trans_res.errcode)
            {
                MessageBox.Show("ზედნადები გაყიდულია.");

                if (DataProvider.PaymentType.Nagdi == paying_method_now)
                {
                    decimal selling_rem_sum = 0.0m;
                    //(from z_nextrem in zed_prod_list
                    //select (z_nextrem.sell_price * z_nextrem.initial_pieces)).Sum();
                    foreach (Remainder next_selling_rem in zed_prod_list.ToArray())
                    {
                        selling_rem_sum += next_selling_rem.sell_price * next_selling_rem.initial_pieces;
                    }
                    //gayidulis gadaricxva
                    info payforsellingzed_info = ProductInfo_Main_Form.conn.TransferMoney(
                        all_buyers[buyer_chooser.SelectedIndex].saidentifikacio_kodi
                        , DataProvider.MoneyTransferType.Take
                        , DateTime.Now
                        , selling_rem_sum
                        , typeof(Buyer)
                        , DataProvider.MoneyTransferPurpose.PayFor
                        , cb_mt_store_id.SelectedIndex
                        , typeof(Zednadebi)
                        , zed_ident_code_txt.Text
                        //zednadebistvis gadaxdaze mgoni ar girs gaformeba cashier-ze da cashbox-ze
                        , 0 //ProductInfo_Main_Form.ActiveCashBoxID
                        , 0 //ProductInfo_Main_Form.ActiveCashierID
                        );
                    MessageBox.Show(payforsellingzed_info.details, payforsellingzed_info.errcode.ToString());
                }
                this.Close();
            }
            else if (404 == trans_res.errcode)
            {
                MessageBox.Show("ამ რაოდენობის პროდუქტები საწყობში აღარაა დარჩენილი! ");
            }
            else
            {
                MessageBox.Show("მოხდა შეცდომა. ზედნადები არ გაყიდულა! ");
            }
        }