Exemple #1
0
        protected void custSubmit_Click(object sender, EventArgs e)
        {
            var cnt = 0;

            if (cnt >= 1)
            {
                this.tblCustInfo.Rows.RemoveAt(1);
                for (int i = 1; i < 3; i++)
                {
                    this.tblOrders.Rows.RemoveAt(i);
                }
            }

            this.lblOrdersNull.Visible  = false;
            this.lblRepairsNull.Visible = false;

            this.tblCustInfoTableHeadings.Visible = this.tblCustInfo.Visible = this.lblCustInfo.Visible = false;
            this.tblOrdersTableHeadings.Visible   = this.tblOrders.Visible = this.lblOrders.Visible = false;
            this.tblRepairsTableHeadings.Visible  = this.tblRepairs.Visible = this.lblRepairs.Visible = false;

            custinfoTableAdapter daCustInfo = new custinfoTableAdapter();
            ordersTableAdapter   daOrders   = new ordersTableAdapter();
            repairsTableAdapter  daRepairs  = new repairsTableAdapter();

            try
            {
                if (this.ddlCustomers.SelectedValue != "Pick a Customer...")
                {
                    string[] custFirst = ddlCustomers.SelectedValue.Split(' ');

                    daCustInfo.Fill(dsSales.custinfo, custFirst[0]);
                    daOrders.Fill(dsSales.orders, custFirst[0]);
                    daRepairs.Fill(dsSales.repairs, custFirst[0]);

                    this.tblCustInfoTableHeadings.Visible = this.tblCustInfo.Visible = this.lblCustInfo.Visible = true;

                    foreach (DataRow r in dsSales.custinfo)
                    {
                        TableRow tblRow = new TableRow();

                        TableCell emailAddress = new TableCell();
                        TableCell postalCode   = new TableCell();
                        TableCell custCity     = new TableCell();
                        TableCell custAddress  = new TableCell();
                        TableCell phoneNumber  = new TableCell();
                        TableCell custModel    = new TableCell();
                        TableCell custSerial   = new TableCell();
                        TableCell custType     = new TableCell();

                        emailAddress.Text = r.ItemArray[0].ToString();
                        postalCode.Text   = r.ItemArray[1].ToString();
                        custCity.Text     = r.ItemArray[2].ToString();
                        custAddress.Text  = r.ItemArray[3].ToString();
                        phoneNumber.Text  = r.ItemArray[4].ToString();
                        custModel.Text    = r.ItemArray[5].ToString();
                        custSerial.Text   = r.ItemArray[6].ToString();
                        custType.Text     = r.ItemArray[7].ToString();

                        tblRow.Cells.Add(emailAddress);
                        tblRow.Cells.Add(postalCode);
                        tblRow.Cells.Add(custCity);
                        tblRow.Cells.Add(custAddress);
                        tblRow.Cells.Add(phoneNumber);
                        tblRow.Cells.Add(custModel);
                        tblRow.Cells.Add(custSerial);
                        tblRow.Cells.Add(custType);

                        this.tblCustInfo.Rows.Add(tblRow);
                    }

                    if (daOrders.GetData(custFirst[0]).Count() != 0)
                    {
                        this.tblOrdersTableHeadings.Visible = this.tblOrders.Visible = this.lblOrders.Visible = true;

                        foreach (DataRow r in dsSales.orders)
                        {
                            TableRow tblRow = new TableRow();

                            TableCell orderNumber = new TableCell();
                            TableCell orderName   = new TableCell();
                            TableCell orderPrice  = new TableCell();
                            TableCell orderDate   = new TableCell();

                            orderNumber.Text = r.ItemArray[0].ToString();
                            orderName.Text   = r.ItemArray[1].ToString();
                            orderPrice.Text  = r.ItemArray[2].ToString();
                            orderDate.Text   = r.ItemArray[3].ToString();

                            tblRow.Cells.Add(orderNumber);
                            tblRow.Cells.Add(orderName);
                            tblRow.Cells.Add(orderPrice);
                            tblRow.Cells.Add(orderDate);

                            this.tblOrders.Rows.Add(tblRow);
                        }
                    }
                    else
                    {
                        this.lblOrdersNull.Visible = true;
                        this.lblOrdersNull.Text    = "No Orders Found.";
                    }

                    if (daRepairs.GetData(custFirst[0]).Count() != 0)
                    {
                        this.tblRepairsTableHeadings.Visible = this.tblRepairs.Visible = this.lblRepairs.Visible = true;

                        foreach (DataRow r in dsSales.repairs)
                        {
                            TableRow tblRow = new TableRow();

                            TableCell serviceName        = new TableCell();
                            TableCell serviceDescription = new TableCell();
                            TableCell servicePrice       = new TableCell();
                            TableCell serviceOrderIn     = new TableCell();
                            TableCell serviceOrderOut    = new TableCell();
                            TableCell serviceOrderIssue  = new TableCell();

                            serviceName.Text        = r.ItemArray[1].ToString();
                            serviceDescription.Text = r.ItemArray[2].ToString();
                            servicePrice.Text       = r.ItemArray[3].ToString();
                            serviceOrderIn.Text     = r.ItemArray[4].ToString();
                            serviceOrderOut.Text    = r.ItemArray[5].ToString();
                            serviceOrderIssue.Text  = r.ItemArray[6].ToString();

                            tblRow.Cells.Add(serviceName);
                            tblRow.Cells.Add(serviceDescription);
                            tblRow.Cells.Add(servicePrice);
                            tblRow.Cells.Add(serviceOrderIn);
                            tblRow.Cells.Add(serviceOrderOut);
                            tblRow.Cells.Add(serviceOrderIssue);

                            this.tblRepairs.Rows.Add(tblRow);
                        }
                    }
                    else
                    {
                        this.lblRepairsNull.Visible = true;
                        this.lblRepairsNull.Text    = "No Repairs Found.";
                    }
                    cnt++;
                }
                refreshDDL();
            }
            catch (Exception) { }
        }
Exemple #2
0
        public static APIServiceProviderNamespace.main.ordersDataTable GetNotDeliveredOrders()
        {
            try
            {
                InitConnection();

                ordersTableAdapter adapter = new ordersTableAdapter();
                if (adapter.Connection != null)
                    adapter.Connection.Close();

                adapter.Connection = sqlCon;

                return adapter.sp_GetNotDeliveredOrders();
            }
            catch (Exception exObj)
            {
                lastErrorString = exObj.Message;
                return null;
            }
        }
Exemple #3
0
        public static int AddOrder(int oid, string status, DateTime dateordered, DateTime datetodeliver, decimal deliverycost, decimal deliveryprice, bool iscash, decimal additionaldeliverysum, decimal sum, decimal discounted, string source, int projectid, string ordersource, string deliverycity)
        {
            try
            {
                InitConnection();

                ordersTableAdapter adapter = new ordersTableAdapter();
                if (adapter.Connection != null)
                    adapter.Connection.Close();

                adapter.Connection = sqlCon;

                return Convert.ToInt32(adapter.sp_AddOrder(oid, status, dateordered, datetodeliver, deliverycost, deliveryprice, iscash, additionaldeliverysum, sum, discounted, source, projectid, ordersource, deliverycity));
            }
            catch (Exception exObj)
            {
                lastErrorString = exObj.Message;
                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                System.IO.File.AppendAllText(path.Replace("file:\\", "") + "\\dblog.txt", "[AddOrder - " + DateTime.Now.ToString() + "]" + exObj.Message + "\r\n");
            }

            return 0;
        }
Exemple #4
0
        public static bool DeleteOrders(int projectid, DateTime dt)
        {
            try
            {
                InitConnection();

                ordersTableAdapter adapter = new ordersTableAdapter();
                if (adapter.Connection != null)
                    adapter.Connection.Close();

                adapter.Connection = sqlCon;

                adapter.sp_DeleteOrders(projectid, dt);
                return true;
            }
            catch (Exception exObj)
            {
                lastErrorString = exObj.Message;
                string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                System.IO.File.AppendAllText(path.Replace("file:\\", "") + "\\dblog.txt", "[DeleteOrders - " + DateTime.Now.ToString() + "]" + exObj.Message + "\r\n");
            }

            return false;
        }
Exemple #5
0
        public static int GetOrderIDByOID(int oid)
        {
            try
            {
                InitConnection();

                ordersTableAdapter adapter = new ordersTableAdapter();
                if (adapter.Connection != null)
                    adapter.Connection.Close();

                adapter.Connection = sqlCon;

                return Convert.ToInt32(adapter.sp_GetOrderIDbyOID(oid));
            }
            catch (Exception exObj)
            {
                lastErrorString = exObj.Message;
                return 0;
            }
        }