Esempio n. 1
0
 public GINCOTEXFiscalPrinter(List <MDB_SingleItemSale> list, MDB_Sale trans_model)
 {
     companyController   = new CompanyController();
     companyModelData    = companyController.get_company_details();
     this.list           = list;
     this.trans_model    = trans_model;
     this.currentCashier = companyController.getCurrentUser();
 }
Esempio n. 2
0
        }//

        //save the current user
        public int saveCurrentUser(MDB_UserModel user)
        {
            try
            {
                string json = Newtonsoft.Json.JsonConvert.SerializeObject(user);
                File.WriteAllText(PathHelper.get_cur_user_path() + @"current.json", json);
                return(0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return(-1);
            }
        }//
Esempio n. 3
0
        }//

        #endregion



        #region getCurrentUser() and saveCurrentUser(MDB_UserModel user)

        /*CURRENT USER OBJECT*/
        public MDB_UserModel getCurrentUser()
        {
            try
            {
                //open the file
                using (StreamReader r = new StreamReader(PathHelper.get_cur_user_path() + @"current.json"))
                {
                    string        json       = r.ReadToEnd();
                    MDB_UserModel userObject = Newtonsoft.Json.JsonConvert.DeserializeObject <MDB_UserModel>(json);
                    return(userObject);
                }
            }
            catch (Exception ex)
            {
                return(new MDB_UserModel());
            }
        }//
Esempio n. 4
0
        public ProductFinderControl()
        {
            InitializeComponent();

            productController     = new ProductController();
            SoundHelper           = new CustomSoundHelper();
            PathHelper            = new CustomPathHelper();
            currentListOfProducts = new List <MDB_ProductModel>();

            storeItemsDataGridView.DoubleBuffered(true);

            currentUser         = productController.getCurrentUser();
            currentUserLbl.Text = currentUser.full_name;

            //logo
            Image image = Image.FromFile(PathHelper.get_app_images_path() + "logo.png");

            this.goToDashBoardBtn.BackgroundImage = image;
        }
Esempio n. 5
0
        }//

        //login
        public MDB_UserModel login_user(MDB_UserModel user)
        {
            try {
                string q = "SELECT * FROM workers WHERE username= '******' AND password='******' LIMIT 1;";
                DBResults = DBManager.getListFromQuery(q, "MDB_UserModel");
                // System.Windows.Forms.MessageBox.Show(DBResults.sys_message);
                if (DBResults.status == 0)
                {
                    var li = new List <MDB_UserModel>(DBResults.result_data.Cast <MDB_UserModel>());
                    return(li[0]);
                }
                else
                {
                    MessageBox.Show("" + DBResults.sys_message);
                    //System.Windows.Forms.MessageBox.Show(DBResults.sys_message);
                    return(null);
                }
            }catch (Exception ex) {
                return(null);
            }
        }
Esempio n. 6
0
        private void loginBtn_Click_1(object sender, EventArgs e)
        {
            loadingLbl.Text    = "signing in ...";
            loadingLbl.Visible = true;
            if (usernameTxt.Text == null || usernameTxt.Text == "" || passwordTxt.Text == null || passwordTxt.Text == "")
            {
                MessageBox.Show("Username and password are required!!");
            }
            //MessageBox.Show(usernameTxt.Text + ":" + passwordTxt.Text);
            MDB_UserModel res = userController.login_user(new MDB_UserModel()
            {
                username = usernameTxt.Text,
                password = passwordTxt.Text
            });

            if (res != null)
            {
                int r = userController.saveCurrentUser(res);
                if (r == 0)
                {
                    loadingLbl.Text = "OK";
                    //System.Threading.Thread.Sleep(2000);

                    var f = new POSForm();
                    f.ShowDialog();
                    this.Close();
                }
                else
                {
                    loadingLbl.Text = "Cant Save current user!!";
                }
            }
            else
            {
                loadingLbl.Text = "Sorry invalid credentials!!";
            }
        }
Esempio n. 7
0
        //
        //paying attemp 2 --paying:
        private void paymentAttemp()
        {
            //current user
            MDB_UserModel workerObj = this.saleController.getCurrentUser();

            if (customerNameTxt.Text == "")
            {
                customerNameTxt.Text = "CASH";
            }
            try{
                MDB_Sale model = new MDB_Sale
                {
                    trans_no         = commonUtil.getRandomReceiptTransNo(),
                    customer_id      = -1,
                    store_id         = -1,
                    worker_id        = workerObj.id,
                    sales_count      = cashSummary.counts,
                    description      = "",
                    payment_method   = paymentModeTxt.Text,
                    amt_req          = cashSummary.total_overall,
                    amt_paid         = Convert.ToSingle(paidAmtTxt.Text),
                    amt_change       = Convert.ToSingle(changeAmtLbl.Text),
                    amt_vat          = printReceiptCheckBox.Checked == true ?  cashSummary.total_tax : 0,//VAT added if receipt printed
                    amt_discount     = cashSummary.total_discount,
                    source           = "OFFICE",
                    customer_name    = customerNameTxt.Text,
                    customer_phone   = customerPhoneTxt.Text,
                    paid             = paymentModeTxt.Text == "CASH" ? 1 : 0,
                    printed          = printReceiptCheckBox.Checked == true? 1 : 0,
                    paid_date        = saleController.getCurrentDate(),
                    created_date     = saleController.getCurrentDate(),
                    created_time     = Convert.ToDouble(saleController.getCurrentCompactedTimeIn24()),
                    created_datetime = saleController.getCurrentDateAndTimeIn24(),
                    //remarks = remarks,
                    json_sales = Newtonsoft.Json.JsonConvert.SerializeObject(this.itemsListForReceipt),
                };

                //save
                int res = saleController.saveThisTransaction(model, this.itemsListForReceipt);
                if (res != 0)
                {
                    MessageBox.Show("FAIL TO SAVE ORDER", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    //fiscal printer / normal thermal printer
                    //printing option
                    if (printReceiptCheckBox.Checked == true)
                    {
                        //GThermalPrinter printer = new GThermalPrinter(itemsListForReceipt, model);
                        //printer.PRINT_NOW();
                        GINCOTEXFiscalPrinter printer = new GINCOTEXFiscalPrinter(itemsListForReceipt, model);
                        printer.PRINT_NOW();
                    }
                    //return back
                    //this.SendPushNotificationCommandToKitchenDepartment();
                    ReceiptGenDepartment.Connecter_in_internal_order_status_results(0);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //MessageBox.Show("FAIL TO RECEIVE ORDER", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }