Exemple #1
0
        protected void btCheckoutStorage_Click(object sender, EventArgs e)
        {
            var id        = int.Parse(hidCheckEquipmentId.Value);
            var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);

            if (null == equipment)
            {
                ShowNotification("./equipment_checkout.aspx", "Cannot find the equipment.", false);
                //return;
            }
            else
            {
                DateTime begin;
                try { begin = DateTime.Parse(outTime.Value.Trim()); }
                catch { begin = DateTime.Now; }

                EquipmentInstance.Update(f => f.id == equipment.id, act =>
                {
                    // 出厂时,如果是普通车辆,则直接划为车辆状态,不参与出库/入库流程
                    if (act.TB_EquipmentModel.TB_EquipmentType.IsVehicle == true)
                    {
                        act.Status = StatusInstance.Find(f => f.IsItVehicle == true).id;
                    }
                    else
                    {
                        act.Status = int.Parse(ddlOuttype.SelectedValue);
                    }
                    act.Customer = int.Parse(hidCheckCustomerId.Value);
                    // 出库时的总运转时间
                    act.OutdoorWorktime = equipment.Runtime;
                    // 出库的时间
                    act.OutdoorTime = begin;
                    // 出库后库存信息置为null
                    act.Warehouse = null;
                });
                equipment = EquipmentInstance.Find(f => f.id == equipment.id);
                // 保存出库历史记录
                var history = StoreInstance.GetObject();
                history.Equipment = equipment.id;
                history.Status    = equipment.Status;
                history.Stocktime = begin;
                // 设备的出入库次数,入库时增1,出库时不变
                history.StoreTimes = equipment.StoreTimes;
                history.Warehouse  = null;
                StoreInstance.Add(history);

                // 保存操作历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("Deliver")).id,
                    ObjectA  = EquipmentInstance.GetFullNumber(equipment) +
                               " check out(" + ddlOuttype.SelectedItem.Text + ") to: " + equipment.TB_Customer.Name
                });

                ShowNotification("./equipment_checkout.aspx", "\"" + EquipmentInstance.GetFullNumber(equipment) + "\" has delivered.");
            }
        }
Exemple #2
0
        private void ShowEquipments()
        {
            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);

            pageIndex = (0 >= pageIndex ? 1 : pageIndex);
            var model = ParseInt(selectedModels.Value);
            var house = ParseInt(hidQueryWarehouse.Value);
            var list  = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords,
                                                                      f => f.Terminal == (int?)null && f.Deleted == false && (model <= 0 ? f.Model >= 0 : f.Model == model) &&
                                                                      (house <= 0 ? (f.Warehouse >= 0 || f.Warehouse == (int?)null) : f.Warehouse == house) &&
                                                                      (f.Number.IndexOf(txtQueryNumber.Value.Trim()) >= 0), null);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"11\">No records, You can change the condition and try again.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    // 入库记录
                    var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true);
                    // 出库记录
                    var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false);

                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));

                    html += "<tr title=\"click to dispatch work\">" +
                            "<td class=\"in-tab-txt-b\">" + cnt + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" + (n == obj.Model ? "-" : ("<a>" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: left !important;\">" + Utility.GetEquipmentFunctional(obj.Functional.Value) + "</td>" +
                            "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" +
                            "<td class=\"in-tab-txt-b\"></td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_inquiry.aspx", divPagging);
            }
        }
        private void SaveNewEquipment()
        {
            var value     = hidNewInstorage.Value;
            var equipment = JsonConverter.ToObject <TB_Equipment>(value);
            // 查找是否有相同型号的相同设备号码
            var exist = EquipmentInstance.Find(f => f.Model == equipment.Model && f.Number.Equals(equipment.Number) && f.Deleted == false);

            if (null == exist)
            {
                var model  = ModelInstance.Find(f => f.id == equipment.Model);
                var newOne = EquipmentInstance.GetObject();
                newOne.Model = equipment.Model;
                if (model.TB_EquipmentType.IsVehicle == true)
                {
                    // 新增的设备是普通车辆时,直接划为车辆,不参与出库/入库流程
                    newOne.Status = StatusInstance.Find(f => f.IsItVehicle == true).id;
                }
                else
                {
                    newOne.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                }
                newOne.Warehouse  = equipment.Warehouse;
                newOne.Number     = equipment.Number;
                newOne.StoreTimes = equipment.StoreTimes;
                newOne.Functional = equipment.Functional;
                newOne            = EquipmentInstance.Add(newOne);

                // 保存入库信息
                var history = StoreInstance.GetObject();
                history.Equipment = newOne.id;
                history.Status    = newOne.Status;
                history.Stocktime = DateTime.Parse(inDate.Value);
                // 默认第1次入库
                history.StoreTimes = newOne.StoreTimes;
                history.Warehouse  = newOne.Warehouse;
                StoreInstance.Add(history);

                // 保存入库操作历史记录
                SaveHistory(new TB_AccountHistory()
                {
                    ActionId = ActionInstance.Find(f => f.Name.Equals("InStore")).id,
                    ObjectA  = EquipmentInstance.ToString(newOne)
                });

                ShowNotification("./equipment_new_product.aspx",
                                 "New equipment \"" + EquipmentInstance.GetFullNumber(exist) + "\" has been saved.");
            }
            else
            {
                ShowNotification("./equipment_new_product.aspx",
                                 "There has a same number of \"" + EquipmentInstance.GetFullNumber(exist) + "\" exist.", false);
            }
        }
Exemple #4
0
        protected void confirmRental_Click(object sender, EventArgs e)
        {
            // 租赁出库
            if (!HasSessionLose)
            {
                var id        = ParseInt(Utility.Decrypt(hiddenRentalId.Value));
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_rental.aspx", "Cannot find the equipment.", false);
                }
                else
                {
                    DateTime begin;
                    try { begin = DateTime.Parse(beginAt.Value.Trim()); }
                    catch { begin = DateTime.Now; }

                    EquipmentInstance.Update(f => f.id == equipment.id, act =>
                    {
                        act.Status          = StatusInstance.Find(f => f.IsItRental == true).id;
                        act.Customer        = int.Parse(hiddenCustomer.Value);
                        act.OutdoorTime     = begin;
                        act.OutdoorWorktime = equipment.Runtime;
                        act.Warehouse       = null;
                        act.ReclaimTime     = DateTime.Parse(deadLine.Value + " 00:00:00");
                    });

                    equipment = EquipmentInstance.Find(f => f.id == equipment.id);
                    // 保存出库历史记录
                    var history = StoreInstance.GetObject();
                    history.Equipment = equipment.id;
                    history.Status    = equipment.Status;
                    history.Stocktime = begin;
                    // 设备的出入库次数,入库时增1,出库时不变
                    history.StoreTimes = equipment.StoreTimes;
                    history.Warehouse  = (int?)null;
                    StoreInstance.Add(history);

                    // 保存操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Rental")).id,
                        ObjectA  = EquipmentInstance.GetFullNumber(equipment) +
                                   " rent to: " + equipment.TB_Customer.Name + ", " +
                                   equipment.OutdoorTime.Value.ToString("yyyy/MM/dd") +
                                   " to " + equipment.ReclaimTime.Value.ToString("yyyy/MM/dd")
                    });

                    ShowNotification("./equipment_rental.aspx", "\"" +
                                     EquipmentInstance.GetFullNumber(equipment) + "\" has rent to " + equipment.TB_Customer.Name + ".");
                }
            }
        }
        protected void btSave_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                // 设备出库
                if (!string.IsNullOrEmpty(hidCustomerId.Value.Trim()) &&
                    !string.IsNullOrEmpty(hidEquipmentId.Value.Trim()))
                {
                    var obj = EquipmentInstance.Find(f => f.id == ParseInt(hidEquipmentId.Value.Trim()) && f.Deleted == false);
                    if (obj.TB_EquipmentStatusName.IsItInventory == false)
                    {
                        // 如果不在库存状态则提示失败
                        ShowNotification("./equipment_delivery.aspx", "Error: equipment \"" +
                                         obj.TB_EquipmentModel.Code + obj.Number + "\" is not in inventory.", false);
                    }
                    else
                    {
                        EquipmentInstance.Update(f => f.id == obj.id && f.Deleted == false, act =>
                        {
                            act.Status = ParseInt(ddlSituation.SelectedValue);
                            // 出库后库存信息置为null
                            act.Warehouse = (int?)null;
                            act.Customer  = ParseInt(hidCustomerId.Value);
                        });

                        // 保存出库历史记录
                        var history = StoreInstance.GetObject();
                        history.Equipment = obj.id;
                        history.Status    = ParseInt(ddlSituation.SelectedValue);
                        history.Stocktime = DateTime.Now;
                        // 设备的出入库次数,入库时增1,出库时不变
                        history.StoreTimes = obj.StoreTimes;
                        history.Warehouse  = (int?)null;
                        StoreInstance.Add(history);

                        // 保存操作历史记录
                        SaveHistory(new Database.TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("Deliver")).id,
                            ObjectA  = ""
                        });

                        ShowNotification("./equipment_deliver.aspx", "\"" + EquipmentInstance.GetFullNumber(obj) + "\" has delivered.");
                    }
                }
            }
        }
Exemple #6
0
        protected void btSaveChangeWarehouse_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id  = ParseInt(Utility.Decrypt(hidWarehouseEquipmentId.Value));
                var obj = EquipmentInstance.Find(f => f.id == id);
                var tmp = JsonConverter.ToObject <TB_Equipment>(hidWarehouseTo.Value);
                if (obj.TB_EquipmentStatusName.IsItInventory == false)
                {
                    ShowNotification("./equipment_change_warehouse.aspx", "The equipment is not in storage status.", false);
                }
                else if (obj.Warehouse == tmp.Warehouse)
                {
                    ShowNotification("./equipment_change_warehouse.aspx", "The equipment in same warehouse you selected.", false);
                }
                else
                {
                    //var transfer = CodeInstance.Find(f =>
                    //        f.TB_EquipmentStatusName.IsInventory == true && f.Code.Equals("T"));
                    EquipmentInstance.Update(f => f.id == obj.id && f.Deleted == false, act =>
                    {
                        act.Warehouse = tmp.Warehouse;
                        // 状态变为库存转移状态
                        //act.Status = transfer.id;
                    });

                    // 保存转库信息
                    var history = StoreInstance.GetObject();
                    history.Equipment = obj.id;
                    history.Status    = obj.Status;//transfer.id;// 移库状态
                    history.Stocktime = DateTime.Now;
                    // 入库次数
                    history.StoreTimes = obj.StoreTimes;
                    history.Warehouse  = tmp.Warehouse;// 保持目的仓库
                    StoreInstance.Add(history);

                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("Transfer")).id,
                        ObjectA  = EquipmentInstance.GetFullNumber(obj) + ", \"" + obj.TB_Warehouse.Name + "\" to \"" +
                                   WarehouseInstance.Find(f => f.id == tmp.Warehouse).Name + "\""
                    });

                    ShowEquipments();
                }
            }
        }
Exemple #7
0
        protected void btRepairComplete_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id        = int.Parse(hidRepairId.Value);
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_overhaul.aspx", "Cannot find the equipment: object is not exist.", false);
                }
                else
                {
                    EquipmentInstance.Update(f => f.id == equipment.id && f.Deleted == false, act =>
                    {
                        act.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                    });
                    //RepairOK
                    equipment = EquipmentInstance.Find(f => f.id == equipment.id && f.Deleted == false);

                    var history = StoreInstance.GetObject();
                    history.Equipment = equipment.id;
                    // 先保存维修状态
                    history.Status = equipment.Status;
                    // 保存维修完成信息
                    history.Stocktime = DateTime.Now;
                    // 入库次数不变
                    history.StoreTimes = equipment.StoreTimes;
                    history.Warehouse  = equipment.Warehouse;
                    StoreInstance.Add(history);

                    // 保存维修完毕操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("RepairOK")).id,
                        ObjectA  = EquipmentInstance.ToString(equipment)
                    });

                    ShowNotification("./equipment_overhaul.aspx", "Equipment \"" +
                                     EquipmentInstance.GetFullNumber(equipment) + "\" inspection & repair complete, and re-store in warehouse.");
                }
            }
        }
Exemple #8
0
        private void BindEquipment(int terminal, int equipment)
        {
            var ter = TerminalInstance.Find(f => f.id == terminal);

            if (null == ter)
            {
                ShowNotification("./terminal_list.aspx", "Error: Cannot find the terminal.", false);
                return;
            }
            else if (ter.HasBound == true)
            {
                ShowNotification("./terminal_list.aspx", "Error: The terminal \"" + ter.Number + "\" has been bound before this time.", false);
                return;
            }
            var equ = EquipmentInstance.Find(f => f.id == equipment && f.Deleted == false);

            if (null == equ)
            {
                ShowNotification("./terminal_list.aspx", "Error: Cannot find the equipment.", false);
                return;
            }
            else if (equ.Terminal > 0)
            {
                ShowNotification("./terminal_list.aspx", "Error: The equipment \"" +
                                 EquipmentInstance.GetFullNumber(equ) + "\" has bound an other terminal: \"" + equ.TB_Terminal.Number + "\".", false);
                return;
            }

            // 开始绑定流程
            var storage = StatusInstance.Find(f => f.IsItInventory == true);

            EquipmentInstance.Update(f => f.id == equ.id && f.Deleted == false, act =>
            {
                act.Terminal = ter.id;
                // 更新设备的相应信息为终端的信息
                act.OnlineStyle = ter.OnlineStyle;
                act.OnlineTime  = ter.OnlineTime;
                act.Socket      = ter.Socket;
                // 新品等待入库的,绑定终端之后直接确定为库存状态
                act.Status = storage.id;
            });
            TerminalInstance.Update(f => f.id == ter.id, act => { act.HasBound = true; });

            // 保存入库信息
            var history = StoreInstance.GetObject();

            history.Equipment = equ.id;
            history.Status    = storage.id;
            history.Stocktime = DateTime.Now;
            // 绑定终端时,入库次数不变
            history.StoreTimes = equ.StoreTimes;
            history.Warehouse  = equ.Warehouse;
            StoreInstance.Add(history);

            // 保存操作历史记录
            SaveHistory(new TB_AccountHistory()
            {
                ActionId = ActionInstance.Find(f => f.Name.Equals("Bind")).id,
                ObjectA  = "bind equipment " + EquipmentInstance.GetFullNumber(equ) + " and terminal " + ter.Number
            });

            ShowNotification("./terminal_list.aspx", "You have bound \"" + ter.Number + "\" on equipment \"" +
                             EquipmentInstance.GetFullNumber(equ) + "\"");
        }
Exemple #9
0
        /// <summary>
        /// 显示处于修理状态的设备列表
        /// </summary>
        private void ShowOverhaulEquipments()
        {
            var query = txtQueryNumber.Value.Trim();

            // 模糊查询时页码置为空
            if (!string.IsNullOrEmpty(query))
            {
                hidPageIndex.Value = "";
            }

            var totalRecords = 0;
            var pageIndex    = "" == hidPageIndex.Value ? 1 : int.Parse(hidPageIndex.Value);

            pageIndex = (0 >= pageIndex ? 1 : pageIndex);
            var type  = ParseInt(selectedTypes.Value);
            var model = ParseInt(selectedModels.Value);
            var house = ParseInt(hidQueryWarehouse.Value);

            Expression <Func <TB_Equipment, bool> > expression = PredicateExtensions.True <TB_Equipment>();

            if (type > 0)
            {
                expression = expression.And(a => a.TB_EquipmentModel.Type == type);
            }
            if (model > 0)
            {
                expression = expression.And(a => a.Model == model);
            }
            if (house > 0)
            {
                expression = expression.And(a => a.Warehouse == house);
            }
            if (!string.IsNullOrEmpty(query))
            {
                pageIndex  = 1;
                expression = expression.And(a => a.Number.Contains(query));
            }
            expression = expression.And(a => (a.TB_EquipmentStatusName.IsItOverhaul == true && a.Deleted == false && a.Terminal != (int?)null));
            var list       = EquipmentInstance.FindPageList <TB_Equipment>(pageIndex, PageSize, out totalRecords, expression, null);
            var totalPages = totalRecords / PageSize + (totalRecords % PageSize > 0 ? 1 : 0);

            hidTotalPages.Value = totalPages.ToString();

            string html = "";

            if (totalRecords < 1)
            {
                html = "<tr><td colspan=\"15\">No records, You can change the condition and try again.</td></tr>";
            }
            else
            {
                var cnt = (pageIndex - 1) * PageSize;
                var n   = (int?)null;
                foreach (var obj in list)
                {
                    cnt++;
                    // 入库记录
                    var _in = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, true);
                    // 出库记录
                    var _out = StoreInstance.GetStoreInfo(obj.id, obj.StoreTimes.Value, false);

                    var id = Utility.UrlEncode(Utility.Encrypt(obj.id.ToString()));

                    html += "<tr>" +
                            "<td class=\"in-tab-txt-b\">" + cnt + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + (n == obj.Model ? "-" : obj.TB_EquipmentModel.TB_EquipmentType.Code) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" style=\"text-align: left !important;\">" +
                            (n == obj.Model ? "-" : ("<a id=\"a_" + obj.id + "\" style=\"cursor: pointer;\" data-toggle=\"modal\" data-target=\"#modalCheckout\">" + EquipmentInstance.GetFullNumber(obj) + "</a>")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" style=\"text-align: right !important;\">" + EquipmentBLL.GetRuntime(obj.Runtime + obj.InitializedRuntime, obj.CompensatedHours.Value) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + EquipmentInstance.GetEngStatus(obj) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\" title=\"" + obj.GpsAddress + "\">" + obj.GpsAddress + "</td>" +
                            "<td class=\"in-tab-txt-rb\" title=\"" + EquipmentInstance.GetStatusTitle(obj) + "\">" + EquipmentInstance.GetStatus(obj) + "</td>" +
                            //"<td class=\"in-tab-txt-b\">" + ((byte?)null == obj.Signal ? "-" : obj.Signal.ToString()) + "</td>" +
                            "<td class=\"in-tab-txt-b\">" + Utility.GetOnlineStyle(obj.OnlineStyle, obj.OnlineTime, false) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (null == obj.LastActionTime ? "" : obj.LastActionTime.Value.ToString("yyyy/MM/dd HH:mm")) + "</td>" +
                            "<td class=\"in-tab-txt-rb textoverflow\" title=\"" + EquipmentInstance.GetTerinalTitleInfo(obj) + "\">" + (n == obj.Terminal ? "-" : obj.TB_Terminal.Number) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (null == _in ? "-" : _in.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            "<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_in) + "\">" + StoreInstance.GetStatus(_in) + "</td>" +
                            //"<td class=\"in-tab-txt-b textoverflow\">" + (null == _out ? "-" : _out.Stocktime.Value.ToString("yyyy/MM/dd")) + "</td>" +
                            //"<td class=\"in-tab-txt-b\" title=\"" + StoreInstance.GetStatusTitle(_out) + "\">" + StoreInstance.GetStatus(_out) + "</td>" +
                            "<td class=\"in-tab-txt-b textoverflow\">" + (n == obj.Warehouse ? "-" : obj.TB_Warehouse.Name) + "</td>" +
                            "</tr>";
                }
            }
            tbodyBody.InnerHtml  = html;
            divPagging.InnerHtml = "";
            if (totalRecords > 0)
            {
                ShowPaggings(pageIndex, totalPages, totalRecords, "./equipment_overhaul.aspx", divPagging);
            }
        }
Exemple #10
0
        protected void btSaveOldInStorage_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id    = int.Parse(Utility.Decrypt(Utility.UrlDecode(hidOldInstorage.Value)));
                var exist = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null != exist)
                {
                    bool repaired = false;
                    EquipmentInstance.Update(f => f.id == exist.id && f.Deleted == false, act =>
                    {
                        // 保存仓库信息
                        act.Warehouse = int.Parse(hiddenOldWarehouse.Value);
                        // 清除出厂日期和出厂时运转时间
                        act.OutdoorWorktime = 0;
                        act.OutdoorTime     = null;
                        // 客户信息清除
                        act.Customer   = null;
                        act.StoreTimes = exist.StoreTimes + 1;
                        // 需要维修
                        if (cbRepair.Checked)
                        {
                            repaired   = true;
                            act.Status = StatusInstance.Find(f => f.IsItOverhaul == true).id;
                        }
                        else
                        {
                            act.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                        }
                    });
                    // 重新查询设备信息
                    exist = EquipmentInstance.Find(f => f.id == exist.id && f.Deleted == false);
                    var history = StoreInstance.GetObject();
                    history.Equipment = exist.id;
                    // 保存之前的状态
                    history.Status = exist.Status;
                    // 保存入库信息
                    var      idate = inDate.Value;
                    DateTime dt    = DateTime.Now;
                    if (!string.IsNullOrEmpty(idate))
                    {
                        try { dt = DateTime.Parse(idate); } catch { }
                    }
                    history.Stocktime = dt;
                    // 入库次数加1
                    history.StoreTimes = exist.StoreTimes;
                    history.Warehouse  = exist.Warehouse;
                    StoreInstance.Add(history);

                    // 保存入库操作历史记录
                    SaveHistory(new TB_AccountHistory()
                    {
                        ActionId = ActionInstance.Find(f => f.Name.Equals("InStoreOld" + (repaired ? "Repair" : ""))).id,
                        ObjectA  = EquipmentInstance.ToString(exist)
                    });

                    ShowNotification("./equipment_rental_fleet.aspx", "Equipment has been store in warehouse.");
                }
                else
                {
                    ShowNotification("./equipment_rental_fleet.aspx", "Cannot change storage status: object is not exist.", false);
                }
            }
        }
Exemple #11
0
        protected void btRentalEdit_Click(object sender, EventArgs e)
        {
            if (!HasSessionLose)
            {
                var id        = ParseInt(Utility.Decrypt(hiddenEditId.Value));
                var equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                if (null == equipment)
                {
                    ShowNotification("./equipment_rental.aspx", "Cannot find the equipment.", false);
                }
                else
                {
                    // 延期
                    if (optionExtend.Checked == true)
                    {
                        EquipmentInstance.Update(f => f.id == equipment.id, act =>
                        {
                            act.ReclaimTime = DateTime.Parse(deadLineExtend.Value);
                        });
                        equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                        // 保存操作历史记录
                        SaveHistory(new TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("ExtendRental")).id,
                            ObjectA  = EquipmentInstance.ToString(equipment) + ", Extend rental to: " +
                                       equipment.ReclaimTime.Value.ToString("yyyy/MM/dd")
                        });

                        ShowNotification("./equipment_rental.aspx", "You have extended the rental date.");
                    }
                    else if (optionReclaim.Checked == true)
                    {
                        // 保存之前的状态
                        var history = StoreInstance.GetObject();
                        history.Equipment = equipment.id;
                        history.Status    = equipment.Status;

                        // 更新
                        EquipmentInstance.Update(f => f.id == equipment.id, act =>
                        {
                            // 保存仓库信息
                            act.Warehouse = int.Parse(hiddenWarehouse.Value);
                            // 清除出厂日期和出厂时运转时间
                            act.OutdoorWorktime = 0;
                            act.OutdoorTime     = (DateTime?)null;
                            // 清除到期时间
                            act.ReclaimTime = (DateTime?)null;
                            // 客户信息清除
                            act.Customer   = (int?)null;
                            act.StoreTimes = equipment.StoreTimes + 1;
                            // 需要维修
                            if (cbRepair.Checked)
                            {
                                act.Status = StatusInstance.Find(f => f.IsItOverhaul == true).id;
                            }
                            else
                            {
                                act.Status = StatusInstance.Find(f => f.IsItInventory == true).id;
                            }
                        });
                        // 重新查询
                        equipment = EquipmentInstance.Find(f => f.id == id && f.Deleted == false);
                        // 保存入库信息
                        history.Stocktime = DateTime.Now;
                        // 入库次数加1
                        history.StoreTimes = equipment.StoreTimes;
                        history.Warehouse  = equipment.Warehouse;
                        StoreInstance.Add(history);

                        // 保存入库操作历史记录
                        SaveHistory(new TB_AccountHistory()
                        {
                            ActionId = ActionInstance.Find(f => f.Name.Equals("InStoreOld")).id,
                            ObjectA  = EquipmentInstance.GetFullNumber(equipment) + " recovered"
                        });

                        ShowNotification("./equipment_rental.aspx", "Equipment has been recovered.");
                    }
                }
            }
        }