Exemplo n.º 1
0
        protected void btnYes_Click(object sender, EventArgs e)
        {
            RestClient.DATrackingAPI client = new RestClient.DATrackingAPI();
            ItemDetail result = client.DeleteItemDetail(lbItemIDHead.Text);

            if (result != null)
            {
                panelEdit.Visible    = false;
                panelDeleted.Visible = true;
            }
        }
Exemplo n.º 2
0
        private void ShowSearchResult()
        {
            DataTable dt;

            if (ViewState["result"] == null)
            {
                RestClient.DATrackingAPI client = new RestClient.DATrackingAPI();
                dt = client.QuickSearch(keyword);
                ViewState.Add("result", dt);
            }
            else
            {
                dt = (DataTable)ViewState["result"];
            }

            gvSearchResult.DataSource = dt;
            gvSearchResult.DataBind();
        }
Exemplo n.º 3
0
        private void ShowItemDetail(string itemID)
        {
            lbItemIDHead.Text = itemID;
            ItemDetail dataSource;

            if (ViewState["ItemDetail"] == null)
            {
                RestClient.DATrackingAPI client = new RestClient.DATrackingAPI();
                dataSource = client.GetItemDetail(itemID);
                ViewState.Add("ItemDetail", dataSource);
            }
            else
            {
                dataSource = (ItemDetail)ViewState["ItemDetail"];
            }
            List <ItemDetail> items = new List <ItemDetail>();

            items.Add(dataSource);
            dvItemDetail.DataSource = items;
            dvItemDetail.DataBind();
        }
Exemplo n.º 4
0
        protected void btnItemidCheck_ServerClick(object sender, EventArgs e)
        {
            RestClient.DATrackingAPI client = new RestClient.DATrackingAPI();
            ItemDetail result = client.GetItemDetail(txtItemID.Value);

            if (result != null)
            {
                panelInsert.Visible      = false;
                alertDupplicated.Visible = true;
                linkDuplicated.HRef     += result.ItemID;
                linkDuplicated.InnerText = result.ItemID;
            }
            else
            {
                alertDupplicated.Visible = false;
                panelInsert.Visible      = true;
                TextBox txt = (TextBox)dvItemDetail.FindControl("txtNewItemID");
                if (txt != null)
                {
                    txt.Text = txtItemID.Value;
                }
            }
        }
Exemplo n.º 5
0
        protected void dvItemDetail_ItemUpdating(object sender, DetailsViewUpdateEventArgs e)
        {
            ItemDetail updatedItem = new ItemDetail();

            if (e.NewValues["ItemID"] != null)
            {
                updatedItem.ItemID = e.NewValues["ItemID"].ToString();
            }

            if (e.NewValues["Desciption"] != null)
            {
                updatedItem.Desciption = e.NewValues["Desciption"].ToString();
            }

            if (e.NewValues["AdditionalDetail"] != null)
            {
                updatedItem.AdditionalDetail = e.NewValues["AdditionalDetail"].ToString();
            }

            if (e.NewValues["BudgetSource"] != null)
            {
                updatedItem.BudgetSource = e.NewValues["BudgetSource"].ToString();
            }

            if (e.NewValues["FiscalYear"] != null)
            {
                updatedItem.FiscalYear = e.NewValues["FiscalYear"].ToString();
            }

            if (e.NewValues["Group1"] != null)
            {
                updatedItem.Group1 = e.NewValues["Group1"].ToString();
            }

            if (e.NewValues["DAType1"] != null)
            {
                updatedItem.DAType1 = e.NewValues["DAType1"].ToString();
            }

            if (e.NewValues["DAType2"] != null)
            {
                updatedItem.DAType2 = e.NewValues["DAType2"].ToString();
            }

            if (e.NewValues["SupplierName"] != null)
            {
                updatedItem.SupplierName = e.NewValues["SupplierName"].ToString();
            }

            if (e.NewValues["WarrantyYear"] != null)
            {
                updatedItem.WarrantyYear = e.NewValues["WarrantyYear"].ToString();
            }

            if (e.NewValues["Price"] != null)
            {
                double price;
                if (Double.TryParse(e.NewValues["Price"].ToString(), out price))
                {
                    updatedItem.Price = price;
                }
            }

            if (e.NewValues["CheckInDate"] != null)
            {
                DateTime checkinDate;
                if (DateTime.TryParse(e.NewValues["CheckInDate"].ToString(), out checkinDate))
                {
                    updatedItem.CheckInDate = checkinDate;
                }
            }

            if (e.NewValues["WarrantyExpiredDate"] != null)
            {
                DateTime warrantyExpiredDate;
                if (DateTime.TryParse(e.NewValues["WarrantyExpiredDate"].ToString(), out warrantyExpiredDate))
                {
                    updatedItem.WarrantyExpiredDate = warrantyExpiredDate;
                }
            }

            RestClient.DATrackingAPI client = new RestClient.DATrackingAPI();
            bool result = client.UpdateItemDetail(updatedItem);

            if (result == true)
            {
                ViewState.Remove("ItemDetail");
                dvItemDetail.ChangeMode(DetailsViewMode.ReadOnly);
                ShowItemDetail(lbItemIDHead.Text);
                panelSuccess.Visible = true;
            }
        }
Exemplo n.º 6
0
        protected void dvItemDetail_ItemInserting(object sender, DetailsViewInsertEventArgs e)
        {
            ItemDetail updatedItem = new ItemDetail();

            if (e.Values["ItemID"] != null)
            {
                updatedItem.ItemID = e.Values["ItemID"].ToString();
            }

            if (e.Values["Desciption"] != null)
            {
                updatedItem.Desciption = e.Values["Desciption"].ToString();
            }

            if (e.Values["AdditionalDetail"] != null)
            {
                updatedItem.AdditionalDetail = e.Values["AdditionalDetail"].ToString();
            }

            if (e.Values["BudgetSource"] != null)
            {
                updatedItem.BudgetSource = e.Values["BudgetSource"].ToString();
            }

            if (e.Values["FiscalYear"] != null)
            {
                updatedItem.FiscalYear = e.Values["FiscalYear"].ToString();
            }

            if (e.Values["Group1"] != null)
            {
                updatedItem.Group1 = e.Values["Group1"].ToString();
            }

            if (e.Values["DAType1"] != null)
            {
                updatedItem.DAType1 = e.Values["DAType1"].ToString();
            }

            if (e.Values["DAType2"] != null)
            {
                updatedItem.DAType2 = e.Values["DAType2"].ToString();
            }

            if (e.Values["SupplierName"] != null)
            {
                updatedItem.SupplierName = e.Values["SupplierName"].ToString();
            }

            if (e.Values["WarrantyYear"] != null)
            {
                updatedItem.WarrantyYear = e.Values["WarrantyYear"].ToString();
            }

            if (e.Values["Price"] != null)
            {
                double price;
                if (Double.TryParse(e.Values["Price"].ToString(), out price))
                {
                    updatedItem.Price = price;
                }
            }

            if (e.Values["CheckInDate"] != null)
            {
                DateTime checkinDate;
                if (DateTime.TryParse(e.Values["CheckInDate"].ToString(), out checkinDate))
                {
                    updatedItem.CheckInDate = checkinDate;
                }
            }

            if (e.Values["WarrantyExpiredDate"] != null)
            {
                DateTime warrantyExpiredDate;
                if (DateTime.TryParse(e.Values["WarrantyExpiredDate"].ToString(), out warrantyExpiredDate))
                {
                    updatedItem.WarrantyExpiredDate = warrantyExpiredDate;
                }
            }

            RestClient.DATrackingAPI client = new RestClient.DATrackingAPI();
            ItemDetail result = client.InsertItemDetail(updatedItem);

            if (!string.IsNullOrEmpty(result.ItemID))
            {
                linkNewItemID.HRef     += result.ItemID;
                linkNewItemID.InnerText = result.ItemID;
                panelInsert.Visible     = false;
                panelSuccess.Visible    = true;
                txtItemID.Value         = "";
            }
        }