private void lstFilter_ItemCheck(System.Object eventSender, System.Windows.Forms.ItemCheckEventArgs eventArgs)
        {
            if (loading)
            {
                return;
            }
            short x = 0;

            x = GID.GetItemData(ref lstFilter, ref lstFilter.SelectedIndex);
            if (Convert.ToBoolean(gArray[x, 2]) != lstFilter.GetItemChecked(eventArgs.Index))
            {
                gArray[x, 2] = Convert.ToString(lstFilter.GetItemChecked(lstFilter.SelectedIndex));
            }
        }
        private void frmPOSSecurity_FormClosed(System.Object eventSender, System.Windows.Forms.FormClosedEventArgs eventArgs)
        {
            short x   = 0;
            int   bit = 0;

            for (x = 0; x <= this.lstSecurity.Items.Count - 1; x++)
            {
                if (lstSecurity.GetItemChecked(x))
                {
                    bit = bit + GID.GetItemData(ref lstSecurity, ref x);
                }
            }
            modRecordSet.cnnDB.Execute("UPDATE Person SET Person.Person_SecurityBitPOS = " + bit + " WHERE (((Person.PersonID)=" + gID + "));");
        }
        private void cmdProceed_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string sql = null;

            ADODB.Recordset rs = default(ADODB.Recordset);
            if (lstSupplier.SelectedIndex != -1)
            {
                sql = "INSERT INTO PurchaseOrder ( PurchaseOrder_SupplierID, PurchaseOrder_DayEndID, PurchaseOrder_PersonID, PurchaseOrder_DateCreated, PurchaseOrder_PurchaseOrderStatusID, PurchaseOrder_Reference, PurchaseOrder_AttentionLine ) ";
                sql = sql + "SELECT " + GID.GetItemData(ref this.lstSupplier, ref lstSupplier.SelectedIndex) + ", Company.Company_DayEndID, " + modRecordSet.gPersonID + ", Now(), 1, '" + Strings.Format(DateAndTime.Now, "yyyy mmm dd") + " (Blind)', '' FROM Company;";
                modRecordSet.cnnDB.Execute(sql, , ADODB.ExecuteOptionEnum.adExecuteNoRecords);
                rs = modRecordSet.getRS(ref "SELECT Max(PurchaseOrder.PurchaseOrderID) AS id FROM PurchaseOrder;");
                this.Close();
                My.MyProject.Forms.frmGRV.Create(rs.Fields("id").Value);
            }
        }
        private void doAction(ref bool ltype)
        {
            short x = 0;

            if (ltype)
            {
                modRecordSet.cnnDB.Execute("DELETE GRVTemplateItem.GRVTemplateItem_GRVTemplateID, GRVTemplateItem.GRVTemplateItem_GRVTemplateListID From GRVTemplateItem WHERE (((GRVTemplateItem.GRVTemplateItem_GRVTemplateID)=" + GID.GetItemData(ref cmbTemplate, ref cmbTemplate.SelectedIndex) + ") AND ((GRVTemplateItem.GRVTemplateItem_GRVTemplateListID)=" + Convert.ToInt32(lstItem.SelectedIndex) + "));");
            }
            else
            {
                for (x = 0; x <= lstItem.Items.Count - 1; x++)
                {
                    if (GID.GetItemData(ref lstItem, ref x) == Convert.ToInt32(lstTemplate.SelectedIndex))
                    {
                        lstItem.SelectedIndex = x;
                        return;
                    }
                }
                modRecordSet.cnnDB.Execute("INSERT INTO GRVTemplateItem ( GRVTemplateItem_GRVTemplateID, GRVTemplateItem_GRVTemplateListID, GRVTemplateItem_Order ) VALUES (" + Convert.ToInt32(cmbTemplate.SelectedIndex) + ", " + GID.GetItemData(ref lstTemplate, ref lstTemplate.SelectedIndex) + ", " + lstItem.Items.Count + 1 + ");");
            }
            reorder();
            cmbTemplate_SelectedIndexChanged(cmbTemplate, new System.EventArgs());
        }
Esempio n. 5
0
        private void printA4Person()
        {
            decimal mm           = default(decimal);
            int     lline        = 0;
            int     i            = 0;
            int     lTop         = 0;
            int     lHeight      = 0;
            int     gOffsetLabel = 0;

            System.Drawing.Printing.PrintDocument Printer = new System.Drawing.Printing.PrintDocument();
            System.Drawing.Printing.PrintDocument lObject = new System.Drawing.Printing.PrintDocument();
            int y = 0;

            ADODB.Recordset rsData     = default(ADODB.Recordset);
            int             currentPic = 0;
            int             twipsToMM  = 0;
            int             lLeft      = 0;
            int             lWidth     = 0;
            short           lCol       = 0;
            short           lCols      = 0;
            short           lRows      = 0;
            short           lrow       = 0;

            //Printer.ScaleMode = ScaleModeConstants.vbTwips 'twips
            //twipsToMM = Printer.ScaleWidth
            //Printer.ScaleMode = ScaleModeConstants.vbMillimeters 'mm
            //twipsToMM = twipsToMM / Printer.ScaleWidth
            //Printer.ScaleMode = ScaleModeConstants.vbTwips 'twips
            lObject = Printer;


            string lString1 = null;
            string lString2 = null;

            rs.MoveFirst();

            rsData = modRecordSet.getRS(ref "SELECT * FROM labelItem INNER JOIN label ON labelItem.labelItem_LabelID = label.labelID Where (((label.labelID) = " + rs.Fields("LabelID").Value + ")) ORDER BY label.labelID, labelItem.labelItem_Line;");

            //lLeft = (lObject.Width - (lWidth)) / 2 + (gOffsetLabel * twipsToMM)
            lLeft = 0;
            if (rsData.Fields("Label_Rotate").Value)
            {
                lWidth  = rsData.Fields("label_Height").Value *twipsToMM;
                lHeight = rsData.Fields("label_Width").Value *twipsToMM;
            }
            else
            {
                lWidth  = rsData.Fields("label_width").Value *twipsToMM;
                lHeight = rsData.Fields("label_Height").Value *twipsToMM;
            }
            lTop = rsData.Fields("label_Top").Value *twipsToMM;
            //lCols = CDec(Printer.Width / (lWidth + 60)) - 0.49999
            //lRows = CDec(Printer.Height / (lHeight + 60)) - 0.49999
            for (i = 0; i <= lstPerson.Items.Count - 1; i++)
            {
                if (lstPerson.GetItemChecked(i))
                {
                    rs.Filter = "PersonID=" + GID.GetItemData(ref lstPerson, ref i);
                    rsData.MoveFirst();
                    y = 0;

                    if (y < 0)
                    {
                        y = 0;
                    }
                    //lObject.FontName = "Tahoma"
                    rsData.MoveFirst();
                    if (rsData.RecordCount)
                    {
                        lline = rsData.Fields("labelItem_Line").Value;

                        lLeft = lCol * (lWidth + 60);
                        //lObject.CurrentY = lrow * (lHeight + 60)
                        rsData.MoveFirst();
                        //y = lObject.CurrentY
                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(Me.BackColor)
                        //lObject.Line((lLeft, y) - (lLeft, y + 100))
                        //lObject.Line((lLeft, y) - (lLeft + 100, y))
                        //lObject.Line((lLeft + lWidth, y) - (lLeft + lWidth - 100, y))
                        //lObject.Line((lLeft + lWidth, y) - (lLeft + lWidth, y + 100))
                        //lObject.Line((lLeft + lWidth, lHeight + y) - (lLeft + lWidth, lHeight + y - 100))
                        //lObject.Line((lLeft + lWidth, lHeight + y) - (lLeft + lWidth - 100, lHeight + y))
                        //lObject.Line((lLeft, lHeight + y) - (lLeft, lHeight + y - 100))
                        //lObject.Line((lLeft, lHeight + y) - (lLeft + 100, lHeight + y))
                        //lObject.CurrentY = lrow * (lHeight + 60) + lTop
                        //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                        //y = lObject.CurrentY + 10
                        while (!(rsData.EOF))
                        {
                            if (lline != rsData.Fields("labelItem_Line").Value)
                            {
                                //		y = lObject.CurrentY + 10
                                lline = rsData.Fields("labelItem_Line").Value;
                            }

                            switch (Strings.LCase(Strings.Trim(rsData.Fields("labelItem_Field").Value)))
                            {
                            case "blank":
                                break;

                            //			lObject.FontSize = rsData.Fields("labelItem_Size").Value
                            //				lObject.FontBold = rsData.Fields("labelItem_Bold").Value
                            //'					lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                            //					lObject.Print(" ")
                            case "line":
                                break;

                            //					lObject.Line((15 + lLeft, y) - (lLeft + lWidth, y), System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black))
                            case "code":
                                switch (rsData.Fields("labelItem_Align").Value)
                                {
                                case 1:
                                    break;

                                //printBarcode(lObject, rs.Fields("Person_QuickAccess").Value, lLeft + 90, y)
                                case 2:
                                    break;

                                //printBarcode(lObject, rs.Fields("Person_QuickAccess").Value, lLeft + 90, y)
                                default:
                                    break;
                                    //printBarcode(lObject, rs.Fields("Person_QuickAccess").Value, lLeft, y, lWidth)
                                }
                                break;

                            default:
                                //lObject.FontSize = rsData.Fields("labelItem_Size").Value
                                //lObject.FontBold = rsData.Fields("labelItem_Bold").Value
                                //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                mm       = rsData.Fields("labelItem_Field").Value;
                                lString1 = rs.Fields(mm).Value;
                                switch (rsData.Fields("labelItem_Align").Value)
                                {
                                case 1:
                                    break;
                                //lObject.PSet(New Point[](lLeft + 90, y))
                                //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                //lObject.Print(lString1)

                                case 2:
                                    break;
                                //lObject.PSet(New Point[](lLeft + lWidth - lObject.TextWidth(lString1) - 90, y))
                                //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                //lObject.Print(lString1)

                                case 3:
                                    splitStringA4(ref lObject, ref lWidth, ref lString1, ref lString2);
                                    //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                    //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                    //lObject.Print(lString1)
                                    //y = lObject.CurrentY + 10
                                    //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.White)
                                    lString1 = lString2;
                                    break;

                                //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                //lObject.Print(lString1)
                                default:
                                    break;
                                    //lObject.PSet(New Point[](CShort(lLeft + (lWidth - lObject.TextWidth(lString1)) / 2), y))
                                    //lObject.ForeColor = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black)
                                    //lObject.Print(lString1)
                                }
                                break;
                            }
                            rsData.moveNext();
                        }
                        lCol = lCol + 1;
                        if (lCol >= lCols)
                        {
                            lCol = 0;
                            lrow = lrow + 1;
                            //If (lrow + 1) * lHeight > lObject.Height Then
                            //Printer.NewPage()
                            //lrow = -1
                            //End If
                        }
                    }
                }
            }
            //Printer.EndDoc()
        }
        private string getSQL()
        {
            string sql     = null;
            bool   gl      = false;
            string lWhere  = null;
            short  x       = 0;
            string lString = null;

            //If 1 = 1 Then lWhere = lWhere & " AND (Sale.Sale_SaleChk=False)"
            if (chkOutCon.CheckState)
            {
                lWhere = lWhere + " AND (Consignment_CompleteSaleID Is Null)";
            }
            if (chkNoCon.CheckState)
            {
                lWhere = lWhere + " AND (ConsignmentID Is Null)";
            }

            if (chkRevoke.CheckState)
            {
                lWhere = lWhere + " AND (SaleItem_Revoke=True)";
            }
            if (chkReversal.CheckState)
            {
                lWhere = lWhere + " AND (SaleItem_Reversal=True)";
            }
            if (chkFC.CheckState)
            {
                lWhere = lWhere + " AND (Sale_PaymentType=8)";
            }

            lString = "";
            for (x = 0; x <= this.lstChannel.Items.Count - 1; x++)
            {
                if (this.lstChannel.GetItemChecked(x))
                {
                    lString = lString + " OR Sale_ChannelID=" + GID.GetItemData(ref lstChannel, ref x);
                }
            }
            if (!string.IsNullOrEmpty(lString))
            {
                lString = " AND (" + Strings.Mid(lString, 4) + ")";
                lWhere  = lWhere + lString;
            }

            lString = "";
            for (x = 0; x <= this.lstPerson.Items.Count - 1; x++)
            {
                if (this.lstPerson.GetItemChecked(x))
                {
                    lString = lString + " OR Sale_PersonID=" + GID.GetItemData(ref lstPerson, ref x);
                }
            }
            if (!string.IsNullOrEmpty(lString))
            {
                lString = " AND (" + Strings.Mid(lString, 4) + ")";
                lWhere  = lWhere + lString;
            }

            lString = "";
            for (x = 0; x <= this.lstPOS.Items.Count - 1; x++)
            {
                if (this.lstPOS.GetItemChecked(x))
                {
                    lString = lString + " OR Sale_POSID=" + GID.GetItemData(ref lstPOS, ref x);
                }
            }
            if (!string.IsNullOrEmpty(lString))
            {
                lString = " AND (" + Strings.Mid(lString, 4) + ")";
                lWhere  = lWhere + lString;
            }

            lString = "";
            gl      = false;
            for (x = 0; x <= this.lstSaleref.Items.Count - 1; x++)
            {
                if (this.lstSaleref.GetItemChecked(x))
                {
                    if (x == 0)
                    {
                        lString = lString + " Sale_CardRef <>''";
                        gl      = true;
                    }
                    else if (x == 1)
                    {
                        if (gl == true)
                        {
                            lString = lString + " OR Sale_OrderRef <>''";
                        }
                        else
                        {
                            lString = lString + " Sale_OrderRef <>''";
                            gl      = true;
                        }
                    }
                    else if (x == 2)
                    {
                        if (gl == true)
                        {
                            lString = lString + " OR Sale_SerialRef <>''";
                        }
                        else
                        {
                            lString = lString + " Sale_SerialRef <>''";
                        }
                    }
                }
            }

            if (!string.IsNullOrEmpty(lString))
            {
                lString = " AND (" + Strings.Mid(lString, 2) + ")";
                lWhere  = lWhere + lString;
            }

            if (!string.IsNullOrEmpty(lWhere))
            {
                lWhere = " WHERE " + Strings.Mid(lWhere, 6);
            }

            //FROM OLD BO code               sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, [Person_FirstName] & ' ' & [Person_LastName] AS PersonName,aPerson1.Person_Comm FROM SaleItem INNER JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson1 ON Sale.Sale_PersonID = aPerson1.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID "
            //added new Mgr field below      sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, [Person_FirstName] & ' ' & [Person_LastName] AS PersonName,aPerson.Person_Comm FROM SaleItem INNER JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID "
            //query copy of report SELECT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, [Person_FirstName] & ' ' & [Person_LastName] AS PersonName, aPerson.Person_Comm FROM SaleItem INNER JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID WHERE (((Sale.Sale_PosID)=12) AND ((SaleItem.SaleItem_Reversal)=True));

            if (chkOutCon.CheckState)
            {
                //sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, aPerson.Person_FirstName & ' ' & aPerson.Person_LastName AS PersonName, aPerson.Person_Comm, aPerson1.Person_FirstName & ' ' & aPerson1.Person_LastName AS MgrName FROM (SaleItem INNER JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment INNER JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID) LEFT JOIN aPerson1 ON Sale.Sale_ManagerID = aPerson1.PersonID "
                sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, aPerson.Person_FirstName & ' ' & aPerson.Person_LastName AS PersonName, aPerson.Person_Comm, aPerson1.Person_FirstName & ' ' & aPerson1.Person_LastName AS MgrName, aPOS1.POS_Name FROM ((SaleItem INNER JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment INNER JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID) LEFT JOIN aPerson1 ON Sale.Sale_ManagerID = aPerson1.PersonID) INNER JOIN aPOS1 ON Sale.Sale_PosID = aPOS1.POSID ";
            }
            else
            {
                //sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, aPerson.Person_FirstName & ' ' & aPerson.Person_LastName AS PersonName, aPerson.Person_Comm, aPerson1.Person_FirstName & ' ' & aPerson1.Person_LastName AS MgrName FROM (SaleItem RIGHT JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID) LEFT JOIN aPerson1 ON Sale.Sale_ManagerID = aPerson1.PersonID "
                sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, aPerson.Person_FirstName & ' ' & aPerson.Person_LastName AS PersonName, aPerson.Person_Comm, aPerson1.Person_FirstName & ' ' & aPerson1.Person_LastName AS MgrName, aPOS1.POS_Name FROM ((SaleItem RIGHT JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID) LEFT JOIN aPerson1 ON Sale.Sale_ManagerID = aPerson1.PersonID) INNER JOIN aPOS1 ON Sale.Sale_PosID = aPOS1.POSID ";
            }

            sql = sql + lWhere;
            Debug.Print(sql);
            return(sql);
        }
        private void doKeyPress(ref short KeyAscii)
        {
            int   lc = 0;
            short x  = 0;

            switch (KeyAscii)
            {
            case 27:
                KeyAscii = 0;
                this.Close();
                break;

            case 13:
                KeyAscii = 0;

                if (lstStockItem.SelectedIndex != -1)
                {
                    lc = CountSelected(ref lstStockItem.Items.Count);
                    if (lc > 0)
                    {
                        if (Interaction.MsgBox("Changes you are about to make will affect : " + lc + " record(s), Do you want to continue?", MsgBoxStyle.ApplicationModal + MsgBoxStyle.Information + MsgBoxStyle.YesNo, "4POS Global Update") == MsgBoxResult.Yes)
                        {
                            modRecordSet.cnnDB.Execute("DELETE * FROM gGlobalUpdate;");
                            for (x = 0; x <= lstStockItem.Items.Count - 1; x++)
                            {
                                if (lstStockItem.GetSelected(x) == true)
                                {
                                    modRecordSet.cnnDB.Execute("INSERT INTO gGlobalUpdate(gStockItemID) VALUES (" + GID.GetItemData(ref lstStockItem, ref x) + ")");
                                }
                            }
                        }
                        else
                        {
                            modRecordSet.cnnDB.Execute("DELETE * FROM gGlobalUpdate;");
                            this.Close();
                        }
                    }
                    else
                    {
                        modRecordSet.cnnDB.Execute("DELETE * FROM gGlobalUpdate;");
                    }
                }
                this.Close();

                break;

            case 65:
            case 97:
                for (x = 0; x <= lstStockItem.Items.Count - 1; x++)
                {
                    lstStockItem.SetSelected(x, true);
                }

                break;
            }
        }
        private void save()
        {
            short  x        = 0;
            string lSQL     = null;
            string lHeading = null;

            ADODB.Recordset rs = new ADODB.Recordset();
            rs = modRecordSet.cnnDB.Execute("DELETE FROM ftDataItem WHERE (ftDataItem_PersonID = " + modRecordSet.gPersonID + ") AND (ftDataItem_FieldName = '" + Strings.Replace(gField, "'", "''") + "')");
            modRecordSet.cnnDB.Execute("DELETE FROM ftData WHERE (ftData_PersonID = " + modRecordSet.gPersonID + ") AND (ftData_FieldName = '" + Strings.Replace(gField, "'", "''") + "')");
            for (x = 0; x <= lstFilter.Items.Count - 1; x++)
            {
                if (lstFilter.GetItemChecked(x))
                {
                    lHeading = lHeading + " OR ''" + gArray[GID.GetItemData(ref lstFilter, ref x), 1] + "''";
                    lSQL     = lSQL + " OR [field] = " + gArray[GID.GetItemData(ref lstFilter, ref x), 0];
                    modRecordSet.cnnDB.Execute("INSERT INTO ftDataItem (ftDataItem_PersonID, ftDataItem_FieldName, ftDataItem_ID) VALUES (" + modRecordSet.gPersonID + ", '" + Strings.Replace(gField, "'", "''") + "', " + gArray[GID.GetItemData(ref lstFilter, ref x), 0] + ")");
                }
            }
            if (!string.IsNullOrEmpty(lSQL))
            {
                lSQL     = "(" + Strings.Mid(lSQL, 4) + ")";
                lHeading = "(" + gHeading + " = " + Strings.Mid(lHeading, 4) + ")";
                modRecordSet.cnnDB.Execute("INSERT INTO ftData (ftData_PersonID, ftData_FieldName, ftData_SQL, ftData_Heading) VALUES (" + modRecordSet.gPersonID + ", '" + Strings.Replace(gField, "'", "''") + "', '" + Strings.Replace(lSQL, "'", "''") + "', '" + Strings.Replace(lHeading, "'", "''") + "')");
            }
        }
        private void reorder()
        {
            short x = 0;

            for (x = 0; x <= lstItem.Items.Count - 1; x++)
            {
                modRecordSet.cnnDB.Execute("UPDATE GRVTemplateItem SET GRVTemplateItem.GRVTemplateItem_Order = " + x + 1 + " WHERE (((GRVTemplateItem.GRVTemplateItem_GRVTemplateID)=" + Convert.ToInt32(cmbTemplate.SelectedIndex) + ") AND ((GRVTemplateItem.GRVTemplateItem_GRVTemplateListID)=" + GID.GetItemData(ref lstItem, ref x) + "));");
            }
        }
        private void cmdUp_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            short x  = 0;
            int   id = 0;

            if (lstItem.SelectedIndex > 0)
            {
                id = Convert.ToInt32(lstItem.SelectedIndex);
                modRecordSet.cnnDB.Execute("UPDATE GRVTemplateItem SET GRVTemplateItem.GRVTemplateItem_Order = " + lstItem.SelectedIndex + 1 + " WHERE (((GRVTemplateItem.GRVTemplateItem_GRVTemplateID)=" + Convert.ToInt32(cmbTemplate.SelectedIndex) + ") AND ((GRVTemplateItem.GRVTemplateItem_GRVTemplateListID)=" + Convert.ToInt32(lstItem.SelectedIndex - 1) + "));");
                modRecordSet.cnnDB.Execute("UPDATE GRVTemplateItem SET GRVTemplateItem.GRVTemplateItem_Order = " + lstItem.SelectedIndex + " WHERE (((GRVTemplateItem.GRVTemplateItem_GRVTemplateID)=" + Convert.ToInt32(cmbTemplate.SelectedIndex) + ") AND ((GRVTemplateItem.GRVTemplateItem_GRVTemplateListID)=" + Convert.ToInt32(lstItem.SelectedIndex) + "));");
                for (x = lstItem.SelectedIndex + 1; x <= lstItem.Items.Count - 1; x++)
                {
                    modRecordSet.cnnDB.Execute("UPDATE GRVTemplateItem SET GRVTemplateItem.GRVTemplateItem_Order = " + x + 1 + " WHERE (((GRVTemplateItem.GRVTemplateItem_GRVTemplateID)=" + Convert.ToInt32(cmbTemplate.SelectedIndex) + ") AND ((GRVTemplateItem.GRVTemplateItem_GRVTemplateListID)=" + GID.GetItemData(ref lstItem, ref x) + "));");
                }
                cmbTemplate_SelectedIndexChanged(cmbTemplate, new System.EventArgs());
                for (x = 0; x <= lstItem.Items.Count - 1; x++)
                {
                    if (GID.GetItemData(ref lstItem, ref x) == id)
                    {
                        lstItem.SelectedIndex = x;
                        lstItem.Focus();
                        break;                         // TODO: might not be correct. Was : Exit For
                    }
                }
            }
        }
        private void cmdNext_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            Printer lPrinter     = null;
            bool    lPrinterName = false;

            ADODB.Recordset rs = default(ADODB.Recordset);
            short           x  = 0;

            //    On Local Error Resume Next
            if (gID)
            {
                modRecordSet.cnnDB.Execute("UPDATE PrintLocation SET PrintLocation.PrintLocation_Name = '" + Strings.Replace(txtName.Text, "'", "''") + "' WHERE (((PrintLocation.PrintLocationID)=" + gID + "));");
            }
            else
            {
                modRecordSet.cnnDB.Execute("INSERT INTO PrintLocation ( PrintLocation_Name, PrintLocation_Disabled ) SELECT '" + Strings.Replace(txtName.Text, "'", "''") + "', False");
                rs  = modRecordSet.getRS(ref "SELECT Max(PrintLocation.PrintLocationID) AS MaxOfPrintLocationID FROM PrintLocation;");
                gID = rs.Fields(0).Value;
            }
            modRecordSet.cnnDB.Execute("DELETE PrintLocationPrinterLnk.* From PrintLocationPrinterLnk WHERE (((PrintLocationPrinterLnk.PrintLocationPrinterLnk_PrintLocationID)=" + gID + "));");
            for (x = 0; x <= this.lstPrinter.Items.Count - 1; x++)
            {
                if (lstPrinter.GetItemChecked(x))
                {
                    modRecordSet.cnnDB.Execute("INSERT INTO PrintLocationPrinterLnk ( PrintLocationPrinterLnk_PrintLocationID, PrintLocationPrinterLnk_PrinterName ) SELECT " + gID + ", '" + Strings.Replace(GID.GetItemString(ref lstPrinter, ref x), "'", "''") + "';");
                }
            }



            this.Close();
        }
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs            = default(ADODB.Recordset);
            ADODB.Recordset rsMajor       = default(ADODB.Recordset);
            ADODB.Recordset rsMinor       = default(ADODB.Recordset);
            string          majorSQL      = null;
            string          majorSQLgroup = null;
            string          minorSQL      = null;
            string          minorSQLgroup = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string sql = null;

            if (Strings.LCase(Convert.ToString(cmbMajor.SelectedIndex)) == Strings.LCase(Convert.ToString(cmbMinor.SelectedIndex)))
            {
                cmbMinor.SelectedIndex = 0;
                System.Windows.Forms.Application.DoEvents();
            }
            switch (Strings.LCase(Convert.ToString(cmbMajor.SelectedIndex)))
            {
            case "supplier":
                majorSQL      = "SELECT Supplier.SupplierID AS sectionAkey, Supplier.Supplier_Name AS sectionAname FROM Supplier ORDER BY Supplier.Supplier_Name;";
                majorSQLgroup = "aStockItem.StockItem_SupplierID";
                break;

            case "pricing group":
                majorSQL      = "SELECT aPricingGroup.PricingGroupID AS sectionAkey, aPricingGroup.PricingGroup_Name AS sectionAname FROM aPricingGroup;";
                majorSQLgroup = "aStockItem.StockItem_PricingGroupID";
                break;

            case "stock group":
                majorSQL      = "SELECT aStockGroup.StockGroupID AS sectionAkey, aStockGroup.StockGroup_Name AS sectionAname FROM aStockGroup;";
                majorSQLgroup = "aStockItem.StockItem_StockGroupID";
                break;

            case "deposit type":
                majorSQL      = "SELECT aDeposit.DepositID AS sectionAkey, aDeposit.Deposit_Name AS sectionAname FROM aDeposit;";
                majorSQLgroup = "aStockItem.StockItem_DepositID";
                break;

            case "shrink type":
                majorSQL      = "SELECT aShrink.ShrinkID AS sectionAkey, aShrink.Shrink_Name AS sectionAname FROM aShrink;";
                majorSQLgroup = "aStockItem.StockItem_ShrinkID";
                break;
            }
            switch (Strings.LCase(Convert.ToString(cmbMinor.SelectedIndex)))
            {
            case "supplier":
                minorSQL      = "SELECT Supplier.SupplierID AS sectionAkey, Supplier.Supplier_Name AS sectionAname FROM Supplier;";
                minorSQLgroup = "aStockItem.StockItem_SupplierID";
                break;

            case "pricing group":
                minorSQL      = "SELECT aPricingGroup.PricingGroupID AS sectionAkey, aPricingGroup.PricingGroup_Name AS sectionAname FROM aPricingGroup;";
                minorSQLgroup = "aStockItem.StockItem_PricingGroupID";
                break;

            case "stock group":
                minorSQL      = "SELECT aStockGroup.StockGroupID AS sectionAkey, aStockGroup.StockGroup_Name AS sectionAname FROM aStockGroup;";
                minorSQLgroup = "aStockItem.StockItem_StockGroupID";
                break;

            case "deposit type":
                minorSQL      = "SELECT aDeposit.DepositID AS sectionAkey, aDeposit.Deposit_Name AS sectionAname FROM aDeposit;";
                minorSQLgroup = "aStockItem.StockItem_DepositID";
                break;

            case "shrink type":
                minorSQL      = "SELECT aShrink.ShrinkID AS sectionAkey, aShrink.Shrink_Name AS sectionAname FROM aShrink;";
                minorSQLgroup = "aStockItem.StockItem_ShrinkID";
                break;
            }
            if (string.IsNullOrEmpty(minorSQL))
            {
                Report.Load("cryGroupSalesMajor.rpt");
                sql = "SELECT " + majorSQLgroup + " AS sectionB, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([exclusiveSum]-[depositSum]) AS price, Sum([exclusiveSum]-[depositSum]) AS content, Sum([exclusiveSum]-[depositSum]-[listCostSum]) AS listProfit, Sum([exclusiveSum]-[depositSum]-[actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost FROM StockList INNER JOIN ";
                sql = sql + "aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY " + majorSQLgroup + ";";
            }
            else
            {
                Report.Load("cryGroupSalesMinor.rpt");
                sql = "SELECT " + majorSQLgroup + " AS sectionA, " + minorSQLgroup + " AS sectionB, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([exclusiveSum]-[depositSum]) AS price, Sum([exclusiveSum]-[depositSum]) AS content, Sum([exclusiveSum]-[depositSum]-[listCostSum]) AS listProfit, Sum([exclusiveSum]-[depositSum]-[actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost FROM StockList INNER JOIN ";
                sql = sql + "aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY " + majorSQLgroup + ", " + minorSQLgroup + ";";
            }
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modReport.getRSreport(ref "SELECT Report.Report_Heading, aCompany.Company_Name FROM aCompany, Report;");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            Report.SetParameterValue("txtDayEnd", rs.Fields("Report_Heading"));
            rs.Close();
            rs = modReport.getRSreport(ref sql);
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            if (rs.BOF | rs.EOF)
            {
                ReportNone.SetParameterValue("txtCompanyName", Report.ParameterFields("txtCompanyName").ToString);
                ReportNone.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString);
                My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString;
                My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone;
                My.MyProject.Forms.frmReportShow.mReport = ReportNone;
                My.MyProject.Forms.frmReportShow.sMode   = "0";
                My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }
            if (string.IsNullOrEmpty(minorSQL))
            {
                rsMajor = modReport.getRSreport(ref majorSQL);
                Report.Database.Tables(1).SetDataSource(rs);
                Report.Database.Tables(2).SetDataSource(rsMajor);
                Report.SetParameterValue("txtTitle", "Group Sales Profit Summary by " + Convert.ToString(cmbMajor.SelectedIndex));
            }
            else
            {
                rsMajor = modReport.getRSreport(ref majorSQL);
                Report.Database.Tables(1).SetDataSource(rsMajor);
                Report.Database.Tables(2).SetDataSource(rs);

                rsMinor = modReport.getRSreport(ref minorSQL);
                Report.Database.Tables(3).SetDataSource(rsMinor);
                Report.SetParameterValue("txtTitle", "Group Sales Profit Summary by " + Convert.ToString(cmbMajor.SelectedIndex) + " by " + GID.GetItemString(ref cmbMinor, ref cmbMinor.SelectedIndex));
            }

            //Report.VerifyOnEveryPrint = True
            My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtTitle").ToString;
            My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
            My.MyProject.Forms.frmReportShow.mReport = Report;
            My.MyProject.Forms.frmReportShow.sMode   = "0";
            My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Esempio n. 13
0
        private void cmdNext_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            //    On Local Error Resume Next
            string sql = null;

            ADODB.Recordset rs = default(ADODB.Recordset);
            switch (gMode)
            {
            case mdSupplier:
                rs                = modRecordSet.getRS(ref "SELECT * FROM Supplier WHERE SupplierID = " + GID.GetItemData(ref lstSupplier, ref lstSupplier.SelectedIndex));
                lblName.Text      = "";
                lblRepName.Text   = "";
                lblRepNumber.Text = "";

                gSupplierID       = rs.Fields("SupplierID").Value;
                lblName.Text      = rs.Fields("Supplier_Name").Value;
                lblRepName.Text   = rs.Fields("Supplier_RepresentativeName").Value + "";
                lblRepNumber.Text = rs.Fields("Supplier_RepresentativeNumber").Value + "";

                doMode(ref mdProcess);
                break;

            case mdProcess:

                exitOrder();
                break;
            }
        }