示例#1
0
        public BatteryItems GetUnassignedBatteryItems(long terminalID)
        {
            //Get unassigned batteries for the specified terminal
            BatteryItems items = null;

            try {
                items = new BatteryItems();
                DataSet ds = fillDataset(USP_BATTERY_UNASSIGNED, TBL_BATTERY_UNASSIGNED, new object[] {});
                if (ds != null)
                {
                    ItemDS itemDS = new ItemDS();
                    itemDS.Merge(ds);
                    for (int i = 0; i < itemDS.BatteryItemTable.Rows.Count; i++)
                    {
                        BatteryItem item = new BatteryItem(itemDS.BatteryItemTable[i]);
                        if (item.TerminalID == terminalID)
                        {
                            items.Add(item);
                        }
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading unassigned battery items.", ex))); }
            return(items);
        }
示例#2
0
        public BatteryItems GetBatteryItems()
        {
            //Update collection of battery items
            BatteryItems items = null;

            try {
                items = new BatteryItems();;
                DataSet ds = fillDataset(USP_BATTERY_VIEW, TBL_BATTERY_VIEW, new object[] {});
                if (ds != null)
                {
                    ItemDS itemDS = new ItemDS();
                    itemDS.Merge(ds);
                    for (int i = 0; i < itemDS.BatteryItemTable.Rows.Count; i++)
                    {
                        BatteryItem item = new BatteryItem(itemDS.BatteryItemTable[i]);
                        item.DriverName  = itemDS.BatteryItemTable[i].IsLastNameNull() ? "" : itemDS.BatteryItemTable[i].LastName.Trim();
                        item.DriverName += !itemDS.BatteryItemTable[i].IsLastNameNull() && !itemDS.BatteryItemTable[i].IsFirstNameNull() ? ", " : "";
                        item.DriverName += itemDS.BatteryItemTable[i].IsFirstNameNull() ? "" : itemDS.BatteryItemTable[i].FirstName.Trim();
                        items.Add(item);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading battery items.", ex))); }
            return(items);
        }
示例#3
0
        public DeviceItems GetPriorDeviceItems()
        {
            //Get a list of all mobile device items available as prior devices
            DeviceItems items = null;

            try {
                items = new DeviceItems();
                DataSet ds = fillDataset(USP_DEVICE_PRIORIDS, TBL_DEVICE_PRIORIDS, new object[] {});
                if (ds != null)
                {
                    ItemDS itemDS = new ItemDS();
                    itemDS.Merge(ds);
                    for (int i = 0; i < itemDS.DeviceItemTable.Rows.Count; i++)
                    {
                        DeviceItem item = new DeviceItem(itemDS.DeviceItemTable[i]);
                        if (!itemDS.DeviceItemTable[i].IsDriverIDNull())
                        {
                            item.Driver = GetDriver(itemDS.DeviceItemTable[i].DriverID);
                        }
                        items.Add(item);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading prior device items.", ex))); }
            return(items);
        }
示例#4
0
        public LocalDriver GetDriver(int driverID)
        {
            //Get an exisitng driver
            LocalDriver driver = null;

            try {
                LocalDrivers drivers = GetDrivers(0, true);
                for (int i = 0; i < drivers.Count; i++)
                {
                    if (drivers[i].DriverID == driverID)
                    {
                        driver = drivers[i];
                        ItemDS  itemDS = new ItemDS();
                        DataSet ds     = fillDataset(USP_BATTERY_ASSIGNMENTS, TBL_BATTERY_ASSIGNMENTS, new object[] { });
                        if (ds != null)
                        {
                            itemDS.Merge(ds);
                            BatteryItemAssignments assignments        = new BatteryItemAssignments();
                            ItemDS.BatteryItemAssignmentTableRow[] da = (ItemDS.BatteryItemAssignmentTableRow[])itemDS.BatteryItemAssignmentTable.Select("DriverID=" + driver.DriverID);
                            for (int j = 0; j < da.Length; j++)
                            {
                                BatteryItemAssignment assignment = new BatteryItemAssignment(da[j]);
                                assignments.Add(assignment);
                            }
                            driver.Assignments = assignments;
                        }
                        break;
                    }
                }
                //DataContractSerializer dcs = new DataContractSerializer(typeof(LocalDriver));
                //System.IO.MemoryStream ms = new System.IO.MemoryStream();
                //dcs.WriteObject(ms,driver);
                //ms.Seek(0,System.IO.SeekOrigin.Begin);
                //System.IO.StreamReader sr = new System.IO.StreamReader(ms);
                //string xml = sr.ReadToEnd();
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading enterprise driver.", ex))); }
            return(driver);
        }
示例#5
0
        public LocalDrivers GetBatteryItemAssignments()
        {
            //Get a collection of battery item assignments
            LocalDrivers drivers = null;

            try {
                drivers = new LocalDrivers();
                DataSet ds1 = fillDataset(USP_BATTERY_DRIVERS, TBL_BATTERY_DRIVERS, new object[] { });
                if (ds1 != null)
                {
                    ItemDS  itemDS = new ItemDS();
                    DataSet ds2    = fillDataset(USP_BATTERY_ASSIGNMENTS, TBL_BATTERY_ASSIGNMENTS, new object[] { });
                    if (ds2 != null)
                    {
                        itemDS.Merge(ds2);
                    }

                    LocalDriverDS driverDS = new LocalDriverDS();
                    driverDS.Merge(ds1);
                    for (int i = 0; i < driverDS.LocalDriverTable.Rows.Count; i++)
                    {
                        LocalDriver            driver             = new LocalDriver(driverDS.LocalDriverTable[i]);
                        BatteryItemAssignments assignments        = new BatteryItemAssignments();
                        ItemDS.BatteryItemAssignmentTableRow[] da = (ItemDS.BatteryItemAssignmentTableRow[])itemDS.BatteryItemAssignmentTable.Select("DriverID=" + driver.DriverID);
                        for (int j = 0; j < da.Length; j++)
                        {
                            BatteryItemAssignment assignment = new BatteryItemAssignment(da[j]);
                            assignments.Add(assignment);
                        }
                        driver.Assignments = assignments;
                        drivers.Add(driver);
                    }
                }
            }
            catch (Exception ex) { throw new FaultException <TerminalsFault>(new TerminalsFault(new ApplicationException("Unexpected error while reading battery item assignments.", ex))); }
            return(drivers);
        }
 private async void Init()
 {
     Items = await ItemDS.GetItemsAsync();
 }
示例#7
0
    protected void btnBuy_Click(object sender, EventArgs e)
    {
        decimal CustomerBalance;
        decimal Price = 0;
        decimal CashInHand;
        decimal AdminBalance  = 0;
        decimal SellerBalance = 0;
        decimal AgencyFee;


        //Retrieve Customer Balance which meet account number and security code from Account
        DataView dv = (DataView)AccountDS.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView dr in dv)
        {
            if (txtAccountNumber.Text == dr[0].ToString() && txtSecurityCode.Text == dr[1].ToString())
            {
                CustomerBalance = decimal.Parse(dr[2].ToString());
                //Retrieve Price from Item
                DataView dv1 = (DataView)ItemDS.Select(DataSourceSelectArguments.Empty);
                foreach (DataRowView dr1 in dv1)
                {
                    Price = decimal.Parse(dr1[5].ToString());     //Retrieve Price From Item
                }
                if (CustomerBalance > Price)
                {
                    CashInHand = CustomerBalance - Price;

                    if (CashInHand >= 1000)
                    {
                        Session["Balance"] = CashInHand.ToString();
                        AccountDS.Update();

                        txtAccountNumber.Text = "";
                        txtSecurityCode.Text  = "";

                        //Retrieve Admin Balance from Account and plus agency fee and update it
                        DataView dv2 = (DataView)AccountForAdminDS.Select(DataSourceSelectArguments.Empty);
                        foreach (DataRowView dr2 in dv2)
                        {
                            AdminBalance = decimal.Parse(dr2[0].ToString());
                            break;
                        }
                        AdminBalance       = AdminBalance + (Price * (decimal)0.05);
                        Session["Balance"] = AdminBalance.ToString();
                        AccountForAdminDS.Update();

                        //Retrieve Seller Balance and plus item's amount
                        DataView dv3 = (DataView)AccountForSellerDS.Select(DataSourceSelectArguments.Empty);
                        foreach (DataRowView dr3 in dv3)
                        {
                            SellerBalance = decimal.Parse(dr3[0].ToString());
                        }

                        SellerBalance      = SellerBalance + (Price - (Price * (decimal)0.05));
                        Session["Balance"] = SellerBalance.ToString();
                        AccountForSellerDS.Update();



                        Session["PurchaseDate"] = DateTime.Now.ToShortDateString();

                        SqlDataSourceUpdate.Update();

                        int pid;
                        try
                        {
                            SqlConnection conn = new SqlConnection(@"Data Source=LAEMON-PC\GROUP3_SERVER;Initial Catalog=ITSocietyDB;User ID=sa;Password=group3");
                            SqlCommand    cmd  = new SqlCommand("select max(purchaseID) from PurchaseInfo", conn);
                            conn.Open();
                            SqlDataReader rader1 = cmd.ExecuteReader();
                            rader1.Read();
                            pid = int.Parse(rader1[0].ToString());
                            pid++;
                            conn.Close();
                        }
                        catch (Exception)
                        {
                            pid = 1;
                        }

                        Session["pid"] = pid;
                        PurchaseDS.Insert();

                        lblMsg.Text = "Successfully Purchased! Thank You For Purchasing";

                        lbtnPurchase.Visible = false;
                        pnlPurchase.Visible  = false;
                        break;
                    }
                    else
                    {
                        lblMsg.Text = "Your Balance is lower than 1000 Kyats!";
                    }
                }
                else
                {
                    lblMsg.Text = "Your Balance is not enough for purchase!";
                }
                break;
            }
            else
            {
                lblMsg.Text = "Your Informatin is not Valid!";
            }
        }
    }