Example #1
0
 public frmSearchProductButton(cls_POSTransaction transaction, cls_product lastprod)
 {
     InitializeComponent();
     fncFilter.set_theme_color(this);
     amountBefore     = transaction.get_productlist().get_totalamount();
     lastaddedproduct = lastprod;
 }
Example #2
0
        public int create_invoice(cls_POSTransaction trans)
        {
            string datetime_d = trans.getdatetime().ToString("yyyy-MM-dd HH:mm:ss");
            string branchid   = cls_globalvariables.BranchCode;
            string terminalno = cls_globalvariables.terminalno_v;

            long userwid = trans.getclerk().getsyncid();

            long next_ornumber = get_nextornumber();

            long   next_SyncId = GetAndInsertNextSyncId("saleshead");
            string sSQL        = @"UPDATE `saleshead` SET
                                `branchid` = '" + branchid + @"', 
                                `date` = '" + datetime_d + @"', 
                                `userid` = '" + userwid + @"', 
                                `lastmodifiedby` = '" + userwid + @"', 
                                `lastmodifieddate` = NOW(), 
                                `datecreated` = NOW(),  
                                `ornumber` = '" + next_ornumber + @"',  
                                `terminalno` = '" + terminalno + @"'
                            WHERE `SyncId` = '" + next_SyncId + @"'";

            setdb(sSQL);

            trans.setORnumber(next_ornumber);
            trans.setSyncId(next_SyncId);
            return(0);
        }
Example #3
0
 public ctrl_payment(Label lblTotal_d, Label lblTender_d, Label lblRemaining_d)
 {
     this.lblTotal     = lblTotal_d;
     this.lblTender    = lblTender_d;
     this.lblRemaining = lblRemaining_d;
     this.POSTrans     = null;
 }
Example #4
0
 public void initial_display()
 {
     mode_product_display(0);
     this.POSTrans          = null;
     this.lblTotal.Text     = "0.00";
     this.lblTender.Text    = "0.00";
     this.lblRemaining.Text = "0.00";
 }
Example #5
0
 public ctrl_otherinfo(ToolStripStatusLabel lblclerkname_d, ToolStripStatusLabel tsslcheckername_d, Label lblmode_d,
                       ToolStripStatusLabel lblcustomer_d, ToolStripStatusLabel tsslcustomermemo_d, ToolStripStatusLabel tsslmember_d, ToolStripStatusLabel tsslwarning_d)
 {
     this.tsslclerkname    = lblclerkname_d;
     this.tsslcheckername  = tsslcheckername_d;
     this.lblmode          = lblmode_d;
     this.tsslcustomer     = lblcustomer_d;
     this.tsslcustomermemo = tsslcustomermemo_d;
     this.tsslmember       = tsslmember_d;
     this.tsslwarning      = tsslwarning_d;
     this.POSTrans         = null;
 }
Example #6
0
        private void SaveBitmap(cls_POSTransaction temp_tran, bool isVoid)
        {
            int    width  = Convert.ToInt32(origwidth * (zoompercent / (decimal)100));
            int    height = Convert.ToInt32(origheight * (zoompercent / (decimal)100));
            Bitmap bmp    = new Bitmap(width, height);

            bmp.SetResolution(zoompercent, zoompercent);
            fncHardware.printpage_receipt(null, null, bmp, temp_tran, isVoid, true);
            bmp.Save(cls_globalvariables.mydocumentpath + "Receipt.jpg");
            bmp.Dispose();
            Bitmap bitmap;

            using (var bmpTemp = new Bitmap(cls_globalvariables.mydocumentpath + "Receipt.jpg"))
                bitmap = new Bitmap(bmpTemp);
            pbPreview.Image = bitmap;
        }
Example #7
0
        public void UpdateDGV(cls_POSTransaction tran)
        {
            if (cls_globalvariables.ads_url_v == "")
            {
                return;
            }

            dgvProduct.DataSource = null;
            lblTender.Text        = "P 0.00";
            lblChange.Text        = "P 0.00";
            lblORNumber_d.Text    = tran.getORnumber().ToString();
            ctrl_productgrid ctrlprod = new ctrl_productgrid(dgvProduct);

            ctrlprod.set_databinding(tran.get_productlist().get_dtproduct());
            dgvProduct.DataSource = ctrlprod.get_productgrid().DataSource;
            lblTotalAmount.Text   = "P " + tran.get_productlist().get_totalamount().ToString("N2");
            lblItemCount.Text     = tran.get_productlist().get_productlist().Count.ToString();
        }
Example #8
0
        private void LoadReceipt(long or_num)
        {
            if (or_num == 0)
            {
                ClearGraphics(pbPreview);
                return;
            }
            cls_POSTransaction temp_tran = new cls_POSTransaction();

            temp_tran.set_transaction_by_ornumber(or_num);

            if (((temp_tran.getShow() == 0) && (temp_tran.getStatus() == 0)) ||
                (temp_tran.getSyncId() == 0))
            {
                ClearGraphics(pbPreview);
                fncFilter.alert(cls_globalvariables.warning_ornumber_invalid);
                return;
            }

            string checkIfVoidSql = @"SELECT Count(*) as cnt FROM Saleshead WHERE (`status`=0) AND `SyncId` = '" + temp_tran.getSyncId() + @"'";
            bool   isVoid         = Convert.ToBoolean(mySQLFunc.getdb(checkIfVoidSql).Rows[0]["cnt"]);

            SaveBitmap(temp_tran, isVoid);
        }
Example #9
0
 public void set_databinding(cls_POSTransaction tran)
 {
     this.POSTran = tran;
 }
Example #10
0
 public ctrl_CustomerDisplay(SerialPort sport_d)
 {
     sport          = sport_d;
     this.POSTran   = null;
     sport.PortName = "COM" + cls_globalvariables.com_v;
 }
Example #11
0
        public int save_transaction(cls_POSTransaction trans)
        {
            string  datetime_d   = trans.getdatetime().ToString("yyyy-MM-dd HH:mm:ss");
            string  branchid     = cls_globalvariables.BranchCode;
            long    salesheadwid = trans.getSyncId();
            long    customerid   = trans.getcustomer().getwid();
            string  customername = trans.getcustomer().getfullname();
            decimal adjust       = trans.getadjust();
            string  seniorno     = trans.getsenior().get_idnumber();
            string  seniorname   = trans.getsenior().get_fullname();
            long    userid       = trans.getclerk().getsyncid();
            long    memberid     = trans.getmember().getSyncId();
            long    checkerid    = trans.getchecker().getsyncid();
            decimal totalamt     = trans.get_productlist().get_totalamount();
            bool    iswholesale  = trans.get_productlist().get_iswholesale();
            bool    isnonvat     = trans.get_productlist().get_isnonvat();
            decimal discount     = trans.getdiscount();
            decimal totalpaidamt = trans.getpayments().get_totalamount();

            decimal t  = trans.get_productlist().get_totalamount();
            decimal t2 = trans.get_productlist().get_totalamount_no_head_discount();
            decimal headDiscountPercentage = (t2 == 0) ? 0 : (t / t2);

            decimal                       cash               = trans.getpayments().get_cash();
            decimal                       mem_points         = trans.getpayments().get_points();
            decimal                       change             = trans.get_changeamount();
            List <cls_cardinfo>           creditcards        = trans.getpayments().get_creditcard();
            List <cls_cardinfo>           debitcards         = trans.getpayments().get_debitcard();
            List <cls_giftcheque>         giftchequesnew     = trans.getpayments().get_giftchequenew();
            List <cls_CustomPaymentsInfo> custompaymentsinfo = trans.getpayments().get_custompayments();
            string        sSQLcd         = "";
            List <string> tempStringList = new List <string>();
            //              DO NOT DELETE
            //            //MEMBER (Priority since it will be run on main branch)
            //            if (trans.getmember().getwid() != 0)
            //            {
            //                List<string> memberTransactionListString = new List<string>();
            //                if (mem_points != 0)
            //                {
            //                    tempStringList = get_next_wid_withlock_main_liststring("memberpointtrans");
            //                    foreach (string str in tempStringList)
            //                        memberTransactionListString.Add(str);
            //                    string sSQLmemberpoint_d = @"UPDATE `memberpointtrans` SET
            //                                            `memberid` = " + trans.getmember().getwid() + @",
            //                                            `branchid` = " + branchid + @",
            //                                            `type` = 3,
            //                                            `referencewid` = " + salesheadwid.ToString() + @",
            //                                            `amount` = " + mem_points + @",
            //                                            `status` = 1,
            //                                            `date` = NOW(),
            //                                            `status` = 1,
            //                                            `datecreated` = NOW(),
            //                                            `lastmodifieddate` = NOW(),
            //                                            `userid` = " + userid + @",
            //                                            `lastmodifiedby` = " + userid + @"
            //                                           WHERE `SyncId` = @syncid_d;";
            //                    memberTransactionListString.Add(sSQLmemberpoint_d);
            //                }
            //                if (trans.getmember().getwid() != 0)
            //                {
            //                    decimal point_earn = trans.get_memberpoint_earn();
            //                    List<string> temp = get_next_wid_withlock_main_liststring("memberpointtrans");
            //                    foreach (string str in temp)
            //                        memberTransactionListString.Add(str);
            //                    string sSQLmemberpoint = @"UPDATE `memberpointtrans` SET
            //                                            `memberid` = " + trans.getmember().getwid() + @",
            //                                            `branchid` = " + branchid + @",
            //                                            `type` = 1,
            //                                            `referencewid` = " + salesheadwid.ToString() + @",
            //                                            `amount` = " + point_earn.ToString("N2") + @",
            //                                            `status` = 1,
            //                                            `date` = NOW(),
            //                                            `datecreated` = NOW(),
            //                                            `lastmodifieddate` = NOW(),
            //                                            `userid` = " + userid + @",
            //                                            `lastmodifiedby` = " + userid + @"
            //                                           WHERE `SyncId` = @syncid_d;";
            //                    memberTransactionListString.Add(sSQLmemberpoint);
            //                }
            //                //'select' is purposely lower cased for exec_trans method
            //                memberTransactionListString.Add(@"select 'SUCCESS';");
            //                if (!mySQLFunc.check_connection_main() || exec_trans_main(memberTransactionListString, 3) != "SUCCESS")
            //                    return 1;
            //            }

            string        discquery            = @"";
            List <string> transactionQueryList = new List <string>();
            string        sSQL = "";

            sSQL = @"UPDATE `saleshead` SET
                        `salesman` = " + trans.getsalesman().getsyncid().ToString() + @",
                        `status` = 1, 
                        `customerid` = " + customerid + @", 
                        `customername` = '" + escapeString(customername) + @"',
                        `date` = NOW(),
                        `adjust` = " + adjust + @", 
                        `discount1` = " + discount + @",
                        `seniorno` = '" + seniorno + @"', 
                        `seniorname` = '" + escapeString(seniorname) + @"',
                        `ornumber` = '" + trans.getORnumber() + @"',
                        `userid` = '" + userid + @"',
                        `branchid` = '" + branchid + @"',                     
                        `lastmodifiedby` = " + userid + @", 
                        `lastmodifieddate` = NOW(), 
                        `memberid` = " + memberid + @", 
                        `checkerid` = " + checkerid + @",
                        `iswholesale` = " + iswholesale + @",
                        `isnonvat` = " + isnonvat.ToString() + @"
                        WHERE `SyncId` = " + salesheadwid;

            //Console.WriteLine(sSQL);
            //setdb(sSQL);
            transactionQueryList.Add(sSQL);

            foreach (cls_product prod in trans.get_productlist().get_productlist())
            {
                string qty   = prod.getQty().ToString("G29");
                string price = (prod.getPrice()).ToString();
                string vat   = prod.getVat().ToString();

                cls_user soldby    = (cls_user)prod.getSoldBy();
                long     soldbywid = 0;
                try { soldbywid = soldby.getsyncid(); }
                catch { soldbywid = userid; }

                List <string> temp = GetListStringAndInsertNextSyncId("salesdetail");
                foreach (string str in temp)
                {
                    transactionQueryList.Add(str);
                }
                transactionQueryList.Add("SET @salesdetailwid := @SyncId");
                int    issenior   = (trans.getsenior().get_idnumber().Length >= 1 && prod.getIsSenior() != 0) ? prod.getIsSenior() : 0;
                string sSQLdetail = @"UPDATE `salesdetail` SET
                                `headid` = '" + salesheadwid + @"', 
                                `productid` = '" + prod.getSyncId().ToString() + @"',  
                                `quantity` = '" + qty + @"',   
                                `oprice` = '" + prod.getOrigPrice().ToString() + @"',  
                                `regularDC` = '" + prod.getDiscount().ToString() + @"', 
                                `price` = '" + price + @"',  
                                `pprice` = '" + prod.getPurchasePrice().ToString() + @"', 
                                `vat` = '" + vat + @"',
                                `soldby` = '" + soldbywid + @"',  
                                `memo` = '" + prod.getMemo() + @"'
                            WHERE `SyncId` = @salesdetailwid";
                //Console.WriteLine(sSQLdetail);
                //setdb(sSQLdetail);
                transactionQueryList.Add(sSQLdetail);
            }

            tempStringList = GetListStringAndInsertNextSyncId("collectionhead");
            foreach (string str in tempStringList)
            {
                transactionQueryList.Add(str);
            }
            transactionQueryList.Add(@"SET @collectionheadwid := @syncid_d");
            string sSQLch = @"UPDATE `collectionhead` SET
                                `customerid` = " + customerid + @", 
                                `collectiondate` = NOW(), 
                                `userid` = " + userid + @",  
                                `status` = 1,
                                `branchid` = " + branchid + @", 
                                `lastmodifieddate` = NOW(), 
                                `lastmodifiedby` = " + userid + @", 
                                `datecreated` = NOW(),
                                `memo` = '" + trans.getpayments().get_memo() + @"',
                                `show` = 1
                            WHERE `SyncId` = @collectionheadwid";

            //Console.WriteLine(sSQLch);
            //setdb(sSQLch);
            transactionQueryList.Add(sSQLch);

            string sSQLcs = @"INSERT INTO `collectionsales`
                            (`headid`, `saleswid`, `amount`)
                            VALUES
                            ( @collectionheadwid, " + salesheadwid + ", " + (totalpaidamt - trans.get_changeamount()) + ")";

            //Console.WriteLine(sSQLcs);
            //setdb(sSQLcs);
            transactionQueryList.Add(sSQLcs);

            if (cash != 0)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = 1, 
                                `amount` = " + cash + @"
                           WHERE `SyncId` = @syncid_d";

                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
            }

            if (change > 0)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = 1,
                                `amount` = -" + change + @"
                           WHERE `SyncId` = @syncid_d";

                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
            }

            foreach (cls_cardinfo creditcard in creditcards)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = 5, 
                                `amount` = " + creditcard.getamount() + @"
                           WHERE `SyncId` = @syncid_d";

                //Console.WriteLine(sSQLcd);
                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
                transactionQueryList.Add("SET @collectiondetailwid = @syncid_d");

                tempStringList = GetListStringAndInsertNextSyncId("poscardpayment");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `poscardpayment` SET
                            `collectiondetailid` = @collectiondetailwid, 
                            `cardsettingwid` = '" + cls_globalfunc.getCreditDebiCardInfo(creditcard.getcardno()) + @"', 
                            `cardno` = '" + creditcard.getcardno() + @"', 
                            `fullname` = '" + escapeString(creditcard.getname()) + @"',
                            `expdate` = '" + creditcard.getexpdate().ToString("yyyy-MM-dd") + @"', 
                            `type` = '0', 
                            `approvalcode` = '" + escapeString(creditcard.getapprovalcode()) + @"',
                            `amount` = '" + creditcard.getamount() + @"'
                           WHERE `SyncId` = @syncid_d";
                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
            }

            foreach (cls_cardinfo debitcard in debitcards)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = 6, 
                                `amount` = " + debitcard.getamount() + @"
                           WHERE `SyncId` = @syncid_d";

                //Console.WriteLine(sSQLcd);
                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
                transactionQueryList.Add("SET @collectiondetailwid = @syncid_d");

                tempStringList = GetListStringAndInsertNextSyncId("poscardpayment");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `poscardpayment` SET
                            `collectiondetailid` = @collectiondetailwid, 
                            `cardno` = '" + debitcard.getcardno() + @"', 
                            `fullname` = '" + escapeString(debitcard.getname()) + @"',
                            `expdate` = '" + debitcard.getexpdate().ToString("yyyy-MM-dd") + @"', 
                            `type` = '1', 
                            `approvalcode` = '" + escapeString(debitcard.getapprovalcode()) + @"',
                            `amount` = '" + debitcard.getamount() + @"'
                           WHERE `SyncId` = @syncid_d";
                //Console.WriteLine(sSQLcd);
                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
            }

            foreach (cls_giftcheque giftchequenew in giftchequesnew)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = 13,
                                `amount` = " + giftchequenew.getamount() + @"
                           WHERE `SyncId` = @syncid_d";

                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
                transactionQueryList.Add("SET @collectiondetailwid = @syncid_d");

                tempStringList = GetListStringAndInsertNextSyncId("posgiftchequepayment");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `posgiftchequepayment` SET
                            `collectiondetailid` = @collectiondetailwid, 
                            `giftchequeno` = '" + giftchequenew.get_referenceno() + @"', 
                            `expdate` = '" + giftchequenew.getexpdate().ToString("yyyy-MM-dd") + @"', 
                            `memo` = '" + escapeString(giftchequenew.get_memo()) + @"', 
                            `amount` = '" + giftchequenew.getamount() + @"'
                           WHERE `SyncId` = @syncid_d";
                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
            }

            foreach (cls_CustomPaymentsInfo custompayment in custompaymentsinfo)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = " + custompayment.get_paymentwid() + @", 
                                `amount` = " + custompayment.get_amount() + @"
                           WHERE `SyncId` = @syncid_d";
                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);

                string field1info = custompayment.get_field1info();
                string field2info = custompayment.get_field2info();
                string field3info = custompayment.get_field3info();
                string field4info = custompayment.get_field4info();
                string field5info = custompayment.get_field5info();
                string field6info = custompayment.get_field6info();

                if (field1info.Length > 0 || field2info.Length > 0 || field3info.Length > 0 ||
                    field4info.Length > 0 || field5info.Length > 0 || field6info.Length > 0)
                {
                    sSQLcs = @"INSERT INTO `poscustompayments`
                            (`detailid`,`field1`,`field2`,`field3`,`field4`,`field5`,`field6`)
                            VALUES
                            ( @syncid_d, '" + escapeString(field1info) + @"',
                                '" + escapeString(field2info) + @"','" + escapeString(field3info) + @"',
                                '" + escapeString(field4info) + @"','" + escapeString(field5info) + @"',
                                '" + escapeString(field6info) + @"')";
                    //setdb(sSQLcs);
                    transactionQueryList.Add(sSQLcs);
                }
            }

            if (mem_points != 0)
            {
                tempStringList = GetListStringAndInsertNextSyncId("collectiondetail");
                foreach (string str in tempStringList)
                {
                    transactionQueryList.Add(str);
                }
                sSQLcd = @"UPDATE `collectiondetail` SET
                                `headid` = @collectionheadwid,
                                `method` = 8, 
                                `amount` = " + mem_points + @"
                           WHERE `SyncId` = @syncid_d";

                //setdb(sSQLcd);
                transactionQueryList.Add(sSQLcd);
            }
            tempStringList = update_synctable_liststring("saleshead", salesheadwid.ToString());
            foreach (string str in tempStringList)
            {
                transactionQueryList.Add(str);
            }

            tempStringList = update_synctable_liststring("collectionhead", "@collectionheadwid");
            foreach (string str in tempStringList)
            {
                transactionQueryList.Add(str);
            }

            transactionQueryList.Add("select 'SUCCESS'");

            string returnVal = exec_trans(transactionQueryList, 5);

            if (returnVal != "SUCCESS")
            {
                return(-1);
            }
            return(0);
        }
Example #12
0
 public void UpdateTenderChange(cls_POSTransaction tran)
 {
     lblTender.Text = "P " + tran.getpayments().get_totalamount().ToString("N2");
     lblChange.Text = "P " + tran.get_changeamount().ToString("N2");
 }
Example #13
0
 public void set_databinding(cls_POSTransaction tran)
 {
     this.POSTrans = tran;
     refresh_display();
 }
Example #14
0
 public void set_databinding(cls_POSTransaction POSTrans_d)
 {
     this.POSTrans = POSTrans_d;
     refresh_display();
 }