Esempio n. 1
0
 protected void btnDelete_Command(object sender, CommandEventArgs e)
 {
     try
     {
         string id = Convert.ToString(e.CommandArgument);
         if (!string.IsNullOrEmpty(id))
         {
             LocationBLL locationBLL = new LocationBLL();
             Locations   location    = new Locations();
             location.LocationId = Convert.ToInt32(QuaintSecurityManager.Decrypt(id));
             if (location.LocationId > 0)
             {
                 if (locationBLL.Delete(location))
                 {
                     Alert(AlertType.Success, "Deleted successfully.");
                     LoadList();
                 }
                 else
                 {
                     Alert(AlertType.Error, "Failed to delete.");
                 }
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to delete.");
     }
 }
Esempio n. 2
0
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            Int32 records = 0;

            if (validateData())
            {
                Entities.Location     oLocation     = new Entities.Location();
                Entities.Headquarters oHeadquarters = new Entities.Headquarters();
                oLocation.code          = Convert.ToInt32(txtCode.Text);
                oHeadquarters.code      = Convert.ToInt32(cboHeadquarters.SelectedValue);
                oLocation.oHeadquarters = oHeadquarters;
                oLocation.building      = txtBuilding.Text;
                oLocation.module        = txtModule.Text;
                oLocation.State         = Convert.ToInt16(cboState.SelectedValue);

                if (LocationBLL.getInstance().exists(oLocation.code))
                {
                    records = LocationBLL.getInstance().modify(oLocation);
                }
                else
                {
                    records = LocationBLL.getInstance().insert(oLocation);
                }

                blockControls();
                loadData();

                if (records > 0)
                {
                    lblMessage.Text = "Datos almacenados correctamente";
                }
            }
        }
        public async Task <IActionResult> GetLocation()
        {
            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_LOCATION", out List <M_Location> c_lstLoc))
                {
                    return(Json(new { data = c_lstLoc }));
                }

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(300),
                    SlidingExpiration = TimeSpan.FromSeconds(60),
                    Priority          = CacheItemPriority.NeverRemove
                };

                using (var locationBll = new LocationBLL())
                {
                    var lstLoc = await locationBll.GetLocation(null);

                    _cache.Set("CACHE_MASTER_LOCATION", lstLoc, options);

                    return(Json(new { data = lstLoc }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }

            //using (var locationBll = new LocationBLL())
            //{
            //    return Json(new { data = await locationBll.GetLocation(null) });
            //}
        }
        public async Task <IActionResult> Edit([Bind("LocationCode,LocationName,LocationDesc,WarehouseId,CompanyCode,Id,Is_Active,Created_Date,Created_By,Updated_Date,Updated_By")] M_Location m_Location)
        {
            if (ModelState.IsValid)
            {
                m_Location.Updated_By = await base.CurrentUserId();

                ResultObject resultObj;

                try
                {
                    using (var locationBll = new LocationBLL())
                    {
                        resultObj = await locationBll.UpdateLocation(m_Location);

                        _cache.Remove("CACHE_MASTER_LOCATION");
                    }

                    return(Json(new { success = true, data = (M_Location)resultObj.ObjectValue, message = "Location Update." }));
                }
                catch (Exception ex)
                {
                    return(Json(new { success = false, data = m_Location, message = ex.Message }));
                }
            }

            var err = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList();

            return(Json(new { success = false, errors = err, data = m_Location, message = "Update Failed" }));
        }
Esempio n. 5
0
        // Handle Event Tour Location
        public void LoadAllLocationDataGridView()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(() =>
                {
                    dgvTourLocationListAll.ShowLoading(true);
                }));
            }
            var locationsData = LocationBLL.ListLocations();

            locations = locationsData.ToList();
            if (InvokeRequired)
            {
                Invoke(new Action(() =>
                {
                    dgvTourLocationListAll.ShowLoading(false);
                    dgvTourLocationListAll.DataSource = locations;

                    dgvTourLocationListAll.Columns["Id"].Visible            = false;
                    dgvTourLocationListAll.Columns["TourLocations"].Visible = false;

                    dgvTourLocationListAll.Columns["Name"].HeaderText = "Tên";
                }));
            }
        }
        public async Task <IActionResult> DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ResultObject resultObj;

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_LOCATION", out List <M_Location> c_lstLoc))
                {
                    var m_Location = c_lstLoc.Find(l => l.Id == id);

                    if (m_Location == null)
                    {
                        return(NotFound());
                    }

                    m_Location.Updated_By = await base.CurrentUserId();

                    using (var locationBll = new LocationBLL())
                    {
                        resultObj = await locationBll.DeleteLocation(m_Location);

                        _cache.Remove("CACHE_MASTER_LOCATION");
                    }

                    return(Json(new { success = true, data = (M_Location)resultObj.ObjectValue, message = "Location Deleted." }));
                }

                using (var locationBll = new LocationBLL())
                {
                    var lstLoc = await locationBll.GetLocation(id);

                    var m_Location = lstLoc.First();

                    if (m_Location == null)
                    {
                        return(NotFound());
                    }

                    m_Location.Updated_By = await base.CurrentUserId();

                    resultObj = await locationBll.DeleteLocation(m_Location);

                    _cache.Remove("CACHE_MASTER_LOCATION");
                }

                return(Json(new { success = true, data = (M_Location)resultObj.ObjectValue, message = "Location Deleted." }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, message = ex.Message }));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 根据地址ID去获取到地址信息
        /// </summary>
        private void GetLocation(HttpContext context, long location_id)
        {
            var location = new LocationBLL().GetLocation(location_id);

            if (location != null)
            {
                context.Response.Write(new EMT.Tools.Serialize().SerializeJson(location));
            }
        }
Esempio n. 8
0
        private void GetCompanyDefaultLocation(HttpContext context, string account_id)
        {
            var location = new LocationBLL().GetLocationByAccountId(long.Parse(account_id));

            if (location != null)
            {
                context.Response.Write(new EMT.Tools.Serialize().SerializeJson(location));
            }
        }
Esempio n. 9
0
        protected void btnActiveOrDeactive_Command(object sender, CommandEventArgs e)
        {
            try
            {
                string id = Convert.ToString(e.CommandArgument);
                if (!string.IsNullOrEmpty(id))
                {
                    LocationBLL locationBLL = new LocationBLL();
                    DataTable   dt          = locationBLL.GetById(Convert.ToInt32(QuaintSecurityManager.Decrypt(id)));
                    if (dt != null)
                    {
                        if (dt.Rows.Count > 0)
                        {
                            string    actionStatus = "Updated";
                            Locations location     = new Locations();
                            location.LocationId   = Convert.ToInt32(Convert.ToString(dt.Rows[0]["LocationId"]));
                            location.LocationCode = Convert.ToString(dt.Rows[0]["LocationCode"]);
                            location.Name         = Convert.ToString(dt.Rows[0]["Name"]);
                            location.Description  = Convert.ToString(dt.Rows[0]["Description"]);
                            location.IsActive     = Convert.ToBoolean(Convert.ToString(dt.Rows[0]["IsActive"]));
                            location.CreatedDate  = (string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["CreatedDate"]))) ? (DateTime?)null : Convert.ToDateTime(Convert.ToString(dt.Rows[0]["CreatedDate"]));
                            location.CreatedBy    = Convert.ToString(dt.Rows[0]["CreatedBy"]);
                            location.CreatedFrom  = Convert.ToString(dt.Rows[0]["CreatedFrom"]);

                            location.UpdatedDate = DateTime.Now;
                            location.UpdatedBy   = UserInfo;
                            location.UpdatedFrom = StationInfo;

                            if (location.IsActive)
                            {
                                location.IsActive = false;
                                actionStatus      = "Deactivated";
                            }
                            else
                            {
                                location.IsActive = true;
                                actionStatus      = "Activated";
                            }

                            if (locationBLL.Update(location))
                            {
                                Alert(AlertType.Success, actionStatus + " successfully.");
                                LoadList();
                            }
                            else
                            {
                                Alert(AlertType.Error, "Failed to update.");
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                Alert(AlertType.Error, "Failed to process.");
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 获取客户详情
        /// </summary>
        private void GetAccDetail(HttpContext context)
        {
            var accountId = context.Request.QueryString["account_id"];

            if (!string.IsNullOrEmpty(accountId))
            {
                var thisAcc = new CompanyBLL().GetCompany(long.Parse(accountId));
                if (thisAcc != null)
                {
                    // 返回客户Id,名称,地址信息
                    var    location   = new LocationBLL().GetLocationByAccountId(thisAcc.id);
                    string city       = "";
                    string provice    = "";
                    string quXian     = "";
                    string address1   = "";
                    string address2   = "";
                    string postalCode = "";
                    int    ticketNum  = 0; // 所有打开的工单的数量
                    int    monthNum   = 0; // 近三十天工单的数量
                    if (location != null)
                    {
                        var thisCity = new d_district_dal().FindById(location.city_id);
                        if (thisCity != null)
                        {
                            city = thisCity.name;
                        }
                        var thisprovice = new d_district_dal().FindById(location.province_id);
                        if (thisprovice != null)
                        {
                            provice = thisprovice.name;
                        }
                        if (location.district_id != null)
                        {
                            var thisquXian = new d_district_dal().FindById((long)location.district_id);
                            if (thisquXian != null)
                            {
                                quXian = thisquXian.name;
                            }
                        }
                        address1 = location.address;
                        address2 = location.additional_address;
                        if (!string.IsNullOrEmpty(location.postal_code))
                        {
                            postalCode = location.postal_code;
                        }
                    }

                    var ticketList = new sdk_task_dal().GetTicketByAccount(thisAcc.id);
                    if (ticketList != null && ticketList.Count > 0)
                    {
                        ticketNum = ticketList.Count;
                    }
                    context.Response.Write(new Tools.Serialize().SerializeJson(new { id = thisAcc.id, name = thisAcc.name, phone = thisAcc.phone, city = city, provice = provice, quXian = quXian, address1 = address1, address2 = address2, ticketNum = ticketNum, monthNum = monthNum, postalCode = postalCode }));
                }
            }
        }
Esempio n. 11
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            Int32 records = LocationBLL.getInstance().delete(location_id);

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "confirmMessage", "$('#confirmMessage').modal('toggle');", true);

            if (records > 0)
            {
                lblMessage.Text = "Localización eliminada correctamente.";
            }
            loadData();
        }
Esempio n. 12
0
        protected void gvLocation_RowEditing(object sender, GridViewEditEventArgs e)
        {
            unlockControls();
            Int32 code = Convert.ToInt32(gvLocation.Rows[e.NewEditIndex].Cells[0].Text);

            Entities.Location oLocation = LocationBLL.getInstance().getLocation(code);
            txtCode.Text = oLocation.code.ToString();
            cboHeadquarters.SelectedValue = oLocation.oHeadquarters.code.ToString();
            txtBuilding.Text       = oLocation.building;
            txtModule.Text         = oLocation.module;
            cboState.SelectedValue = oLocation.State.ToString();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true);
        }
Esempio n. 13
0
 private void LoadList()
 {
     try
     {
         LocationBLL locationBLL = new LocationBLL();
         DataTable   dt          = locationBLL.GetAll();
         rptrList.DataSource = dt;
         rptrList.DataBind();
     }
     catch (Exception)
     {
         //throw;
     }
 }
Esempio n. 14
0
        protected void loadLocation()
        {
            List <Entities.Location> listLocation = new List <Entities.Location>();

            listLocation = LocationBLL.getInstance().getAllActive();
            ListItem oItemS = new ListItem("---- Seleccione ----", "0");

            cboLocation.Items.Add(oItemS);
            foreach (Entities.Location oLocation in listLocation)
            {
                ListItem oItem = new ListItem(oLocation.oHeadquarters.description + " - " + oLocation.building + " - " + oLocation.module, oLocation.code.ToString());
                cboLocation.Items.Add(oItem);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// 删除区域
        /// </summary>
        void DeleteOrganization(HttpContext context)
        {
            bool   result     = false;
            string failReason = string.Empty;
            var    id         = context.Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                result = new LocationBLL().DeleteOrgan(long.Parse(id), LoginUserId, ref failReason);
            }
            else
            {
                failReason = "未获取到相关信息,请刷新页面后重试!";
            }
            WriteResponseJson(new { result = result, reason = failReason });
        }
Esempio n. 16
0
        private void GetLocation()
        {
            LocationBLL pcBll = new LocationBLL();

            drpLocation.Items.Clear();
            drpLocation.Items.Add(new ListItem(LocalizationUtility.GetText("ltrLocationDropTitle", Ci), "-1"));
            IList <PNK_Location> lst = pcBll.GetList(LangInt, string.Empty, 1, 500, out total);

            if (lst != null && lst.Count > 0)
            {
                foreach (PNK_Location item in lst)
                {
                    drpLocation.Items.Add(new ListItem(item.ObjLocDesc.Name, DBConvert.ParseString(item.Id)));
                }
            }
        }
Esempio n. 17
0
        /// <summary>
        ///生产线以及工位信息同步
        /// </summary>
        /// <returns></returns>
        public static void SyncProductionlineProcessOrder(string loginUser)
        {
            ///sql 添加语句
            StringBuilder sql = new StringBuilder();

            ///获取未处理的工艺顺序中间表数据
            List <MesProductionlineProcessOrderInfo> mesProductionlineProcessOrderInfos = new MesProductionlineProcessOrderBLL().GetListByPage("[PROCESS_FLAG] = " + (int)ProcessFlagConstants.Untreated + "", "[ID]", 1, 1000, out int dataCnt);

            if (dataCnt == 0)
            {
                return;
            }

            ///获取所有基础工位信息
            List <LocationInfo> locationInfos = new LocationBLL().GetList(string.Empty, "ID");
            List <long>         dealedIds     = new List <long>();

            /// 循环未处理状态的中间表信息
            foreach (var mesProductionlineProcessOrderInfo in mesProductionlineProcessOrderInfos)
            {
                ///判断是否存在该工位信息. 不存在跳出如果存在更新顺序号码
                LocationInfo maintainPartsInfo = locationInfos.FirstOrDefault(d => d.Plant == mesProductionlineProcessOrderInfo.Enterprise && d.Workshop == mesProductionlineProcessOrderInfo.SiteNo && d.AssemblyLine == mesProductionlineProcessOrderInfo.AreaNo && d.Location == mesProductionlineProcessOrderInfo.Stationcode);
                if (maintainPartsInfo == null)
                {
                    continue;
                }

                /// 如果工位不为空, 进行工位顺序更新
                sql.Append("UPDATE [LES].[TM_BAS_LOCATION] SET  SEQUENCE_NO='" + mesProductionlineProcessOrderInfo.SeqNo + "' WHERE [ID]='" + maintainPartsInfo.Id + "';");
                dealedIds.Add(mesProductionlineProcessOrderInfo.Id);
                continue;
            }

            if (dealedIds.Count > 0)
            {
                ///中间表数据更新为已处理状态, 修改时间,修改人
                sql.Append("update [LES].[TI_IFM_MES_PRODUCTIONLINE_PROCESS_ORDER] "
                           + "set [PROCESS_FLAG] = " + (int)ProcessFlagConstants.Processed + ",[PROCESS_TIME] = GETDATE() , [MODIFY_DATE]=GETDATE(),[MODIFY_USER]='" + loginUser
                           + "' where [ID] in (" + string.Join(",", dealedIds.ToArray()) + ");");
            }

            if (sql.ToString().Length > 0)
            {
                Log.WriteLogToFile(sql.ToString(), AppDomain.CurrentDomain.BaseDirectory + @"\SQL-Log\", DateTime.Now.ToString("yyyyMMddHHmm"));
                BLL.SYS.CommonBLL.ExecuteNonQueryBySql(sql.ToString());
            }
        }
        private void LoadLocation()
        {
            try
            {
                LocationBLL locationBLL = new LocationBLL();
                DataTable   dt          = locationBLL.GetAll();
                ddlLocation.DataSource     = dt;
                ddlLocation.DataTextField  = "Name";
                ddlLocation.DataValueField = "LocationId";
                ddlLocation.DataBind();

                ddlLocation.Items.Insert(0, "--- Please Select ---");
            }
            catch (Exception)
            {
                //throw;
            }
        }
Esempio n. 19
0
        private void LoadDataDropdownlist(DropDownList _drp)
        {
            int         total;
            LocationBLL pcBll = new LocationBLL();
            string      strTemp;

            _drp.Items.Clear();
            _drp.Items.Add(new ListItem(LocalizationUtility.GetText("enuChat_All_none"), int.MinValue.ToString()));
            IList <PNK_Location> lst = pcBll.GetList(Constant.DB.LangId, string.Empty, 1, 300, out total);

            if (lst != null && lst.Count > 0)
            {
                foreach (PNK_Location item in lst)
                {
                    strTemp = item.ObjLocDesc.Name;
                    _drp.Items.Add(new ListItem(strTemp, DBConvert.ParseString(item.Id)));
                }
            }
        }
        // GET: Master/Location/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            ViewBag.CompCode = "ALL*";

            try
            {
                if (_cache.TryGetValue("CACHE_MASTER_LOCATION", out List <M_Location> c_lstLoc))
                {
                    var m_Location = c_lstLoc.Find(l => l.Id == id);

                    if (m_Location == null)
                    {
                        return(NotFound());
                    }

                    return(PartialView(m_Location));
                }

                using (var locationBll = new LocationBLL())
                {
                    var lstLoc = await locationBll.GetLocation(id);

                    var m_Location = lstLoc.First();

                    if (m_Location == null)
                    {
                        return(NotFound());
                    }

                    return(PartialView(m_Location));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { success = false, message = ex.Message }));
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 删除地址
        /// </summary>
        /// <param name="location_id"></param>
        /// <returns></returns>
        public string DeleteLocation(HttpContext context, long location_id)
        {
            var location = new LocationBLL().GetAllQuoteLocation(location_id);

            if (location != null && location.Count > 0)
            {
                return("Occupy");
            }
            else
            {
                var delete_location = new crm_location_dal().GetLocationById(location_id);
                if (new LocationBLL().DeleteLocation(location_id, LoginUserId)) // 删除成功
                {
                    return("Success");
                }
                else
                {
                    return("Fail");
                }
            }
        }
        private void LoadDashboardInfo()
        {
            try
            {
                //Total Guide
                GuideBLL guideBLL = new GuideBLL();
                DataTable dtGuide = guideBLL.GetAll();
                lblTotalGuide.Text = Convert.ToString(Convert.ToInt32(dtGuide.Rows.Count));

                //Total Event
                EventBLL eventBLL = new EventBLL();
                DataTable dtEvent = eventBLL.GetAll();
                lblTotalEvent.Text = Convert.ToString(Convert.ToInt32(dtEvent.Rows.Count));

                //Total Location
                LocationBLL locationBLL = new LocationBLL();
                DataTable dtLocation = locationBLL.GetAll();
                lblTotalLocation.Text = Convert.ToString(Convert.ToInt32(dtLocation.Rows.Count));

                //Total Hotel Reservation
                HotelReservationBLL hotelReservationBLL = new HotelReservationBLL();
                DataTable dtHotelReservation = hotelReservationBLL.GetAll();
                lblTotalHotelReservation.Text = Convert.ToString(Convert.ToInt32(dtHotelReservation.Rows.Count));

                //Total Registration
                RegistrationBLL registrationBLL = new RegistrationBLL();
                DataTable dtRegistration = registrationBLL.GetAll();
                lblTotalRegistration.Text = Convert.ToString(Convert.ToInt32(dtRegistration.Rows.Count));

                //Total Registration
                //SubscribeBLL subscribeBLL = new SubscribeBLL();
                //DataTable dtSubscribe = subscribeBLL.GetAll();
                //lblTotalSubscribe.Text = Convert.ToString(Convert.ToInt32(dtSubscribe.Rows.Count));
            }
            catch (Exception)
            {
                
                throw;
            }
        }
 private void Edit(int id)
 {
     try
     {
         LocationBLL locationBLL = new LocationBLL();
         DataTable   dt          = locationBLL.GetById(id);
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 this.ModelId        = Convert.ToInt32(Convert.ToString(dt.Rows[0]["LocationId"]));
                 this.ModelCode      = Convert.ToString(dt.Rows[0]["LocationCode"]);
                 txtName.Text        = Convert.ToString(dt.Rows[0]["Name"]);
                 txtDescription.Text = Convert.ToString(dt.Rows[0]["Description"]);
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to edit.");
     }
 }
 private void GenerateCode()
 {
     try
     {
         QuaintLibraryManager lib = new QuaintLibraryManager();
         this.ModelCode = CodePrefix.Location + "-" + lib.GetSixDigitNumber(1);
         LocationBLL locationBLL = new LocationBLL();
         DataTable   dt          = locationBLL.GetAll();
         if (dt != null)
         {
             if (dt.Rows.Count > 0)
             {
                 string[] lastCode       = dt.Rows[dt.Rows.Count - 1]["LocationCode"].ToString().Split('-');
                 int      lastCodeNumber = Convert.ToInt32(lastCode[1]);
                 this.ModelCode = CodePrefix.Location + "-" + lib.GetSixDigitNumber(lastCodeNumber + 1);
             }
         }
     }
     catch (Exception)
     {
         Alert(AlertType.Error, "Failed to load.");
     }
 }
Esempio n. 25
0
 private void btnTourLocationAdd_Click(object sender, EventArgs e)
 {
     if (dgvTourLocationListAll.SelectedRows.Count > 0)
     {
         var locationItem    = (Location)dgvTourLocationListAll.SelectedRows[0].DataBoundItem;
         var newTourLocation = new TourLocations
         {
             TourId     = Int32.Parse(tbTourID.Text),
             LocationId = locationItem.Id,
             Location   = LocationBLL.LocationById(locationItem.Id),
         };
         tourLocations.Add(newTourLocation);
         var dataSource = tourLocations.Select((t, index) => new TourLocationDataSource(
                                                   t.TourId,
                                                   t.LocationId,
                                                   t.Location.Name,
                                                   index + 1)).ToList();
         dgvTourLocationList.DataSource = dataSource;
     }
     else
     {
         MessageBox.Show("Vui lòng chọn địa điểm từ danh sách tất cả địa điểm");
     }
 }
Esempio n. 26
0
        /// <summary>
        /// 对页面上的地址相关信息的处理
        /// </summary>
        /// <param name="sale"></param>
        /// <returns></returns>
        private crm_sales_order LocationDeal(crm_sales_order sale)
        {
            var location_id = Request.Form["location_id"];
            var location    = new LocationBLL().GetLocation(long.Parse(location_id));

            if (location == null)
            {
                return(sale);
            }

            if (billTo_use_account_address.Checked)
            {
                sale.bill_to_location_id         = location.id;
                sale.bill_to_use_account_address = 1;
            }
            else
            {
                sale.bill_to_use_account_address = 0;
                var bill_id = Request.Params["billLocationId"];
                if (bill_id == location_id)
                {
                    bill_id = "";
                }
                var bill_location = new crm_location()
                {
                    account_id         = opportunity.account_id,
                    additional_address = Request.Params["bill_address2"],
                    address            = Request.Params["bill_address"],
                    city_id            = string.IsNullOrEmpty(Request.Params["bill_city_id"]) ? 0 : int.Parse(Request.Params["bill_city_id"]),
                    country_id         = 1,
                    district_id        = string.IsNullOrEmpty(Request.Params["bill_district_id"]) ? 0 : int.Parse(Request.Params["bill_district_id"]),
                    is_default         = 0,
                    province_id        = string.IsNullOrEmpty(Request.Params["bill_province_id"]) ? 0 : int.Parse(Request.Params["bill_province_id"]),
                    postal_code        = Request.Params["bill_postcode"],
                };
                if (bill_location.country_id != 0 && bill_location.province_id != 0 && bill_location.city_id != 0 && bill_location.district_id != 0 && (!string.IsNullOrEmpty(bill_location.address)))
                {
                    if (!string.IsNullOrEmpty(bill_id)) // 修改
                    {
                        bill_location.id = long.Parse(bill_id);
                        new LocationBLL().Update(bill_location, GetLoginUserId());
                    }
                    else         // 新增
                    {
                        bill_location.id = new crm_location_dal().GetNextIdCom();
                        new LocationBLL().Insert(bill_location, GetLoginUserId());
                    }
                    sale.bill_to_location_id = bill_location.id;
                }
                else
                {
                    sale.bill_to_location_id = this.sale_order.bill_to_location_id;
                }
            }


            if (shipTo_use_account_address.Checked)
            {
                sale.ship_to_location_id         = location.id;
                sale.ship_to_use_account_address = 1;
            }
            else
            {
                sale.ship_to_use_account_address = 0;
                var ship_id = Request.Params["shipLocationId"];
                if (ship_id == location_id)
                {
                    ship_id = "";
                }
                var ship_location = new crm_location()
                {
                    account_id         = opportunity.account_id,
                    additional_address = Request.Params["ship_address2"],
                    address            = Request.Params["ship_address"],
                    city_id            = string.IsNullOrEmpty(Request.Params["ship_city_id"]) ? 0 : int.Parse(Request.Params["ship_city_id"]),
                    country_id         = 1,
                    district_id        = string.IsNullOrEmpty(Request.Params["ship_district_id"]) ? 0 : int.Parse(Request.Params["ship_district_id"]),
                    is_default         = 0,
                    province_id        = string.IsNullOrEmpty(Request.Params["ship_province_id"]) ? 0 : int.Parse(Request.Params["ship_province_id"]),
                    postal_code        = Request.Params["ship_postcode"],
                };
                if (ship_location.country_id != 0 && ship_location.province_id != 0 && ship_location.city_id != 0 && ship_location.district_id != 0 && (!string.IsNullOrEmpty(ship_location.address)))
                {
                    if (!string.IsNullOrEmpty(ship_id))
                    {
                        ship_location.id = long.Parse(ship_id);
                        new LocationBLL().Update(ship_location, GetLoginUserId());
                    }
                    else
                    {
                        ship_location.id = new crm_location_dal().GetNextIdCom();
                        new LocationBLL().Insert(ship_location, GetLoginUserId());
                    }
                    sale.ship_to_location_id = ship_location.id;
                }
                else
                {
                    sale.ship_to_location_id = this.sale_order.ship_to_location_id;
                }
            }

            if (shipTo_use_bill_to_address.Checked)
            {
                sale.ship_to_location_id         = sale.bill_to_location_id;
                sale.ship_to_use_bill_to_address = 1;
            }
            else
            {
                sale.ship_to_use_bill_to_address = 0;
            }
            return(sale);
        }
Esempio n. 27
0
 protected void loadData()
 {
     gvLocation.DataSource = LocationBLL.getInstance().getAll();
     gvLocation.DataBind();
 }
Esempio n. 28
0
 protected void btnNew_Click(object sender, ImageClickEventArgs e)
 {
     unlockControls();
     txtCode.Text = LocationBLL.getInstance().getNextCode().ToString();
 }
Esempio n. 29
0
        protected void btnReport_Click(object sender, EventArgs e)
        {
            try
            {
                List <Entities.Location> listLocation = LocationBLL.getInstance().getAll();
                System.IO.MemoryStream   memoryStream = new System.IO.MemoryStream();
                text::Document           pdfDoc       = new text::Document(text::PageSize.A4, 10, 10, 10, 10);
                pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
                PdfWriter.GetInstance(pdfDoc, memoryStream);
                pdfDoc.Open();

                String imagepath           = Server.MapPath("../../images/page-icons");
                iTextSharp.text.Image deas = iTextSharp.text.Image.GetInstance(imagepath + "/DEAS-logo.jpg");
                deas.ScaleToFit(140f, 120f);
                //Give space before image
                deas.SpacingBefore = 10f;
                //Give some space after the image
                deas.SpacingAfter = 1f;
                deas.Alignment    = text::Element.ALIGN_LEFT;
                pdfDoc.Add(deas);

                text::Paragraph title = new text::Paragraph();
                title.Font      = text::FontFactory.GetFont("dax-black", 32, new text::BaseColor(0, 51, 102));
                title.Alignment = text::Element.ALIGN_CENTER;
                title.Add("\n\n Reporte de Localizaciones\n\n");
                pdfDoc.Add(title);

                PdfPTable oPTable = new PdfPTable(4);
                oPTable.TotalWidth    = 100;
                oPTable.SpacingBefore = 20f;
                oPTable.SpacingAfter  = 30f;
                oPTable.AddCell("Sede");
                oPTable.AddCell("Edificio");
                oPTable.AddCell("Modulo");
                oPTable.AddCell("Estado");

                if (listLocation.Count > 0)
                {
                    foreach (Entities.Location pLocation in listLocation)
                    {
                        oPTable.AddCell(pLocation.oHeadquarters.description);
                        oPTable.AddCell(pLocation.building);
                        oPTable.AddCell(pLocation.module);
                        oPTable.AddCell((pLocation.State == 1 ? "Activo" : "Inactivo"));
                    }
                }
                else
                {
                    PdfPCell cell = new PdfPCell(new text::Phrase("No existen localizaciones registradas."));
                    cell.Colspan             = 5;
                    cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
                    oPTable.AddCell(cell);
                }

                pdfDoc.Add(oPTable);
                pdfDoc.Close();

                byte[] bytes = memoryStream.ToArray();
                memoryStream.Close();
                Response.Clear();
                Response.ContentType = "application/pdf";
                Response.AddHeader("Content-Disposition", "attachment; filename=Localizacion.pdf");
                Response.ContentType = "application/pdf";
                Response.Buffer      = true;
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(bytes);
                Response.End();
                Response.Close();
            }
            catch (Exception ex)
            {
                Response.Write(ex.ToString());
            }
        }
        public List <Region> GetRegions(int id)
        {
            ILocationBLL locationBll = new LocationBLL();

            return(locationBll.GetRegions(id));
        }