Ejemplo n.º 1
0
        //==============================================================================
        //private void b_stockTake_Click(object sender, EventArgs e)
        //{
        //    //Jika POS tersebut bukan PC Master maka menu ini tidak bisa diakses
        //    if (Properties.Settings.Default.MstrOrChld == "Child")
        //    {
        //        MessageBox.Show("This Menu Can Only Be Accessed By A Master PCss", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        //    }
        //    else
        //    {
        //        label3.Text = "Stock Take";
        //        UC_Stock_Take c = new UC_Stock_Take(this);
        //        p_kanan.Controls.Clear();
        //        if (!p_kanan.Controls.Contains(UC_Stock_Take.Instance))
        //        {
        //            p_kanan.Controls.Add(UC_Stock_Take.Instance);
        //            UC_Stock_Take.Instance.Dock = DockStyle.Fill;
        //            //UC_Stock_Take.Instance.from_form1();
        //            UC_Stock_Take.Instance.id_employee2 = id_employee;
        //            UC_Stock_Take.Instance.nm_employee2 = nama_employee;

        //            //UC_Stock_Take.Instance.retreive(sql);
        //            UC_Stock_Take.Instance.BringToFront();
        //        }
        //        else
        //        {
        //            //UC_Stock_Take.Instance.from_form1();
        //            UC_Stock_Take.Instance.id_employee2 = id_employee;
        //            UC_Stock_Take.Instance.nm_employee2 = nama_employee;
        //            //UC_Stock_Take.Instance.retreive(sql);
        //            UC_Stock_Take.Instance.BringToFront();
        //        }
        //    }

        //}
        //==============================================================================
        private void b_deliveryCust_Click(object sender, EventArgs e)
        {
            LinkApi link = new LinkApi();
            API_DeliveryCustomer deliv_cust = new API_DeliveryCustomer();

            //Jika POS tersebut bukan PC Master maka menu ini tidak bisa diakses
            if (Properties.Settings.Default.MstrOrChld == "Child")
            {
                MessageBox.Show("This Menu Can Only Be Accessed By A Master PCss", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                deliv_cust.getDeliveryCust(link.storeId).Wait();

                label3.Text = "Delivery Customer";
                p_kanan.Controls.Clear();
                if (!p_kanan.Controls.Contains(UC_DeliveryCustomer.Instance))
                {
                    p_kanan.Controls.Add(UC_DeliveryCustomer.Instance);
                    UC_DeliveryCustomer.Instance.Dock = DockStyle.Fill;
                    UC_DeliveryCustomer.Instance.new_();
                    UC_DeliveryCustomer.Instance.holding();
                    UC_DeliveryCustomer.Instance.BringToFront();
                }
                else
                {
                    UC_DeliveryCustomer.Instance.new_();
                    UC_DeliveryCustomer.Instance.holding();
                    UC_DeliveryCustomer.Instance.BringToFront();
                }
            }
        }
Ejemplo n.º 2
0
        private void b_confirmShipping_Click(object sender, EventArgs e)
        {
            String art_id, art_name, qty, deliveryAddress, courier, fromStore, deliveryType, deliveryCustId = "";
            string command;
            CRUD   sql = new CRUD();
            bool   isValid = true, apiResponse;
            API_DeliveryCustomer delivCust = new API_DeliveryCustomer();

            try
            {
                //for (int i = 0; i < dgv_shipping.Rows.Count; i++)
                //{
                //    string type = Convert.ToString(dgv_shipping.Rows[i].Cells["Type"].EditedFormattedValue);
                //    string omniStore = Convert.ToString(dgv_shipping.Rows[i].Cells["FromStore"].Value);
                //    string articleId = Convert.ToString(dgv_shipping.Rows[i].Cells["Article_Id"].Value);

                //    if (type == "")
                //    {
                //        isValid = false;
                //        MessageBox.Show("Please select type in shipping details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //        break;
                //    }
                //    else
                //    {
                //        String cmd_update = "UPDATE transaction_line SET DELIVERYTYPE = '" + type + "' "
                //                            + "WHERE TRANSACTION_ID = '" + l_transaksi2.Text + "' AND OMNISTORECODE = '" + omniStore + "' AND ARTICLE_ID = '" + articleId + "'";
                //        sql.ExecuteNonQuery(cmd_update);
                //    }
                //}

                //if (isValid)
                //{
                ckon.sqlCon().Open();
                command = "SELECT DELIVERY_CUST_ID FROM deliverycustomer WHERE Status = '0'";

                ckon.sqlDataRd = sql.ExecuteDataReader(command, ckon.sqlCon());

                if (ckon.sqlDataRd.HasRows)
                {
                    while (ckon.sqlDataRd.Read())
                    {
                        deliveryCustId = ckon.sqlDataRd["DELIVERY_CUST_ID"].ToString();
                    }
                }


                if (deliveryCustId == "")
                {
                    save_deliveryCust_header();
                    deliveryCustId = final_running_number;

                    command = "SELECT transaction_line.QUANTITY, transaction_line.DELIVERYCUSTADDRESS, transaction_line.OMNICOURIER, transaction_line.OMNISTORECODE, "
                              + "transaction_line.ARTICLE_ID, transaction_line.DELIVERYTYPE FROM transaction_line "
                              + "WHERE transaction_line.TRANSACTION_ID = '" + l_transaksi2.Text + "' AND transaction_line.OMNISTORECODE != '' ORDER BY transaction_line._id ASC";

                    ckon.sqlDataRd = sql.ExecuteDataReader(command, ckon.sqlCon());

                    if (ckon.sqlDataRd.HasRows)
                    {
                        while (ckon.sqlDataRd.Read())
                        {
                            art_id          = ckon.sqlDataRd["ARTICLE_ID"].ToString();
                            qty             = ckon.sqlDataRd["QUANTITY"].ToString();
                            deliveryAddress = ckon.sqlDataRd["DELIVERYCUSTADDRESS"].ToString();
                            courier         = ckon.sqlDataRd["OMNICOURIER"].ToString();
                            fromStore       = ckon.sqlDataRd["OMNISTORECODE"].ToString();
                            deliveryType    = ckon.sqlDataRd["DELIVERYTYPE"].ToString();

                            String cmd_insert = "INSERT INTO deliverycustomer_line (DELIVERY_CUST_ID, ARTICLE_ID, QTY, STORE_FROM, STORE_TO, NO_RESI, COURIER, DELIVERYADDRESS, DELIVERYTYPE) VALUES ('" + deliveryCustId + "','" + art_id + "','" + qty + "','" + fromStore + "','" + store_code + "', '','" + courier + "', '" + deliveryAddress + "','" + deliveryType + "') ";
                            sql.ExecuteNonQuery(cmd_insert);
                        }

                        String cmd_update = "UPDATE deliverycustomer SET TOTAL_QTY = (SELECT SUM(QTY) FROM deliverycustomer_line WHERE DELIVERY_CUST_ID = '" + deliveryCustId + "') "
                                            + "WHERE DELIVERY_CUST_ID = '" + deliveryCustId + "'";
                        sql.ExecuteNonQuery(cmd_update);
                    }
                    else
                    {
                        MessageBox.Show("No shipping", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }

                apiResponse = delivCust.deliveryCustPost(deliveryCustId).Result;
                if (apiResponse)
                {
                    MessageBox.Show("Shipping confirmed", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Make sure you are connected to internet and try again", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                iList.Clear();
                if (ckon.sqlDataRd != null)
                {
                    ckon.sqlDataRd.Close();
                }

                if (ckon.sqlCon().State == ConnectionState.Open)
                {
                    ckon.sqlCon().Close();
                }
            }
        }