コード例 #1
0
        public string Get_MoreShipping_ForEdit(string id)
        {
            Company_EntryBL cbl        = new Company_EntryBL();
            string          jsonresult = string.Empty;

            if (id != null)
            {
                DataTable dtinfo = new DataTable();
                dtinfo = cbl.Get_MoreShipping_ForEdit(id);
                dtinfo.Columns.Add("Total", typeof(System.Int32));
                //int count = 0;
                if (dtinfo.Rows.Count > 0)
                {
                    foreach (DataRow dr in dtinfo.Rows)
                    {
                        dr["Total"] = dtinfo.Rows.Count;
                    }
                    //count = dtinfo.Rows.Count;
                    //ViewBag.Totalcount = count;
                    jsonresult = JsonConvert.SerializeObject(dtinfo);
                    return(jsonresult);
                }
                else
                {
                    jsonresult = JsonConvert.SerializeObject(dtinfo);
                    return(jsonresult);
                }
            }
            return(null);
        }
コード例 #2
0
        public String CompanyUpdate_View_Delete(string id)
        {
            Company_EntryBL bl       = new Company_EntryBL();
            var             AccessPC = System.Environment.MachineName;
            Boolean         result   = bl.CompanyUpdate_View_Delete(id, AccessPC);
            var             sendR    = "";

            if (result == true)
            {
                sendR = "OK";
            }
            else
            {
                sendR = "NOK";
            }
            return(JsonConvert.SerializeObject(sendR));
        }
コード例 #3
0
        // GET: Registrations

        public ActionResult Company_Entry(string id)
        {
            MultipleModel model = new MultipleModel();

            if (Session["CompanyCD"] != null)
            {
                if (id != null)
                {
                    ViewBag.Flag = id;
                    try
                    {
                        M_CompanyModel    MCmodel = new M_CompanyModel();
                        M_CompanyTagModel t       = new M_CompanyTagModel();
                        //M_CompanyBrandModel MCBmodel = new M_CompanyBrandModel();
                        M_BrandModel MBmodel = new M_BrandModel();
                        //M_CompanyShippingModel ms = new M_CompanyShippingModel();
                        //List<M_CompanyShippingModel> MSmodel = new List<M_CompanyShippingModel>();
                        List <M_CompanyTagModel> MTmodel = new List <M_CompanyTagModel>();
                        Company_EntryBL          bl      = new Company_EntryBL();
                        DataSet dsnew = bl.CompanyUpdateView_Edit(id);

                        if (dsnew.Tables.Count > 0)
                        {
                            int count = dsnew.Tables.Count;
                            for (int i = 0; i < count; i++)
                            {
                                DataTable dt = dsnew.Tables[i];
                                if (dt.Rows.Count > 0)
                                {
                                    DataColumnCollection columns = dt.Columns;
                                    if (columns.Contains("CompanyName"))
                                    {
                                        MCmodel.CompanyCD   = dt.Rows[0]["CompanyCD"].ToString();
                                        MCmodel.CompanyName = dt.Rows[0]["CompanyName"].ToString();
                                        MCmodel.Password    = dt.Rows[0]["Password"].ToString();
                                        MCmodel.UserRole    = Convert.ToInt32(dt.Rows[0]["UserRole"]);
                                        MCmodel.ShortName   = dt.Rows[0]["ShortName"].ToString();
                                        MCmodel.ZipCD1      = dt.Rows[0]["CompanyZipCD"].ToString();

                                        MCmodel.Address1      = dt.Rows[0]["Address1"].ToString();
                                        MCmodel.Address2      = dt.Rows[0]["Address2"].ToString();
                                        MCmodel.TelephoneNo   = dt.Rows[0]["TelephoneNo"].ToString();
                                        MCmodel.FaxNo         = dt.Rows[0]["FaxNo"].ToString();
                                        MCmodel.PresidentName = dt.Rows[0]["PresidentName"].ToString();
                                        if (String.IsNullOrWhiteSpace(dt.Rows[0]["RankingFlg"].ToString()))
                                        {
                                            MCmodel.RankingFlg = 2;
                                        }
                                        else
                                        {
                                            MCmodel.RankingFlg = Convert.ToInt32(dt.Rows[0]["RankingFlg"]);
                                        }
                                    }
                                    //if (columns.Contains("ShippingID"))
                                    //{

                                    //        //DataView view1 = new DataView(dt);
                                    //        //DataTable distinctValues1 = view1.ToTable(true, "ShippingID", "ShippingName", "ShippingZipCD", "ShippingAddress1", "ShippingAddress2", "ShippingTelephoneNo","ShippingFaxNo");
                                    //        MSmodel = dt.AsEnumerable().Select(r =>
                                    //    new M_CompanyShippingModel
                                    //    {
                                    //        ShippingID = Convert.ToInt32(r["ShippingID"]),
                                    //        ShippingName = r["ShippingName"].ToString(),
                                    //        ZipCD1 = r["ShippingZipCD"].ToString(),

                                    //        Address1 = r["ShippingAddress1"].ToString(),
                                    //        Address2 = r["ShippingAddress2"].ToString(),
                                    //        TelephoneNO = r["ShippingTelephoneNo"].ToString(),
                                    //        FaxNO = r["ShippingFaxNo"].ToString()
                                    //    }).Distinct().ToList();


                                    //}
                                    if (columns.Contains("Tag"))
                                    {
                                        DataView  view           = new DataView(dt);
                                        DataTable distinctValues = view.ToTable(true, "CompanyCD", "Tag");
                                        MTmodel = distinctValues.AsEnumerable().Select(r =>
                                                                                       new M_CompanyTagModel
                                        {
                                            CompanyCD = r["CompanyCD"].ToString(),
                                            Tag       = r["Tag"].ToString()
                                        }

                                                                                       ).Distinct().ToList();
                                    }
                                    if (columns.Contains("BrandName"))
                                    {
                                        MBmodel.BrandName = dt.Rows[0]["BrandName"].ToString();
                                    }
                                }
                            }
                        }
                        //if (MSmodel.Count < 5)
                        //{
                        //    int sc = MSmodel.Count;
                        //    int tc = 4;
                        //    int nq = tc - sc;
                        //    int O = nq + sc;


                        //    for (int P = sc; P < O; P++)
                        //    {
                        //        ms.CompanyCD = "";
                        //        ms.ShippingID = null;
                        //        ms.ShippingName = "";
                        //        ms.ZipCD1 = "";
                        //        ms.ZipCD2 = "";
                        //        ms.Address1 = "";
                        //        ms.Address2 = "";
                        //        ms.TelephoneNO = "";
                        //        ms.FaxNO = "";

                        //        MSmodel.Add(ms);

                        //    }
                        //}

                        int N  = MTmodel.Count;
                        int M  = 20;
                        int NK = M - N;
                        int n  = N + NK;
                        for (int j = N; j < n; j++)
                        {
                            t.CompanyCD = "";
                            t.Tag       = "";
                            MTmodel.Add(t);
                        }

                        model.TagModel = MTmodel;
                        //model.ShippingModel = MSmodel;
                        model.ComModel    = MCmodel;
                        model.MBrandModel = MBmodel;

                        DataTable       dtinfo1 = new DataTable();
                        Company_EntryBL cbl     = new Company_EntryBL();
                        dtinfo1 = cbl.Get_MoreShipping_ForEdit(id);
                        int totalcount = 0;
                        if (dtinfo1.Rows.Count > 0)
                        {
                            totalcount         = dtinfo1.Rows.Count + 1;
                            ViewBag.Totalcount = totalcount;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                else
                {
                    ViewBag.Flag = "";
                }

                return(View(model));
            }
            else
            {
                return(RedirectToAction("Login", "User"));
            }
        }
コード例 #4
0
        public ActionResult InsertCompany(MultipleModel model)
        {
            Company_EntryBL cbl       = new Company_EntryBL();
            TOSEntities     _entity   = new TOSEntities();
            var             CompanyCD = _entity.M_Company.Where(m => m.CompanyCD.Equals(model.ComModel.CompanyCD)).Select(s => s.CompanyCD).FirstOrDefault();

            if (CompanyCD != null)
            {
                try
                {
                    var option = new TransactionOptions
                    {
                        IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                        Timeout        = TimeSpan.MaxValue
                    };
                    TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option);
                    using (scope)
                    {
                        string PcName = System.Environment.MachineName;

                        //Update Company
                        if (model.ComModel.ZipCD1 != null)
                        {
                            string[] zips = model.ComModel.ZipCD1.Split(new Char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                            string   zip1 = zips[0].ToString();
                            string   zip2 = zips[1].ToString();

                            model.ComModel.ZipCD1 = zip1;
                            model.ComModel.ZipCD2 = zip2;
                        }

                        model.ComModel.UpdateOperator = Session["CompanyCD"].ToString();
                        model.ComModel.UpdateDateTime = DateTime.Now;
                        DataTable dt = cbl.UpdateCompany(model.ComModel, PcName);

                        //Update Company Shipping

                        DataTable dtshipping = new DataTable();
                        using (var reader = ObjectReader.Create(model.ShippingModel, "ShippingID", "ShippingName", "ZipCD1", "ZipCD2", "Address1", "Address2", "TelephoneNO", "FaxNO"))
                        {
                            dtshipping.Load(reader);
                        }
                        for (int k = 0; k < dtshipping.Rows.Count; k++)
                        {
                            string zipcd = dtshipping.Rows[k]["ZipCD1"].ToString();
                            if (!String.IsNullOrWhiteSpace(zipcd))
                            {
                                if (zipcd.Contains("-"))
                                {
                                    string[] zip = zipcd.Split('-');
                                    dtshipping.Rows[k]["ZipCD1"] = zip[0];
                                    dtshipping.Rows[k]["ZipCD2"] = zip[1];
                                }
                            }
                        }

                        cbl.UpdateCompanyShipping(dtshipping, model.ComModel, PcName);

                        //Update Company Tag


                        DataTable dttag = new DataTable();
                        using (var reader = ObjectReader.Create(model.TagModel, "CompanyCD", "Tag"))
                        {
                            dttag.Load(reader);
                        }

                        cbl.UpdateCompanyTag(dttag, model.ComModel, PcName);

                        //Update  Company  Brand
                        if (model.MBrandModel.BrandName != null)
                        {
                            model.MBrandModel.UpdateOperator = Session["CompanyCD"].ToString();

                            cbl.UpdateCompanyBrand(model.MBrandModel, model.ComModel, PcName);
                        }
                        scope.Complete();
                    }
                    TempData["Imsg"] = "success";
                    return(RedirectToAction("Company_Entry"));
                    //return RedirectToAction("CompanyUpdate_View");
                }
                catch (Exception ex)
                {
                    string st = ex.ToString();

                    TempData["Emsg"] = "Unsuccess";

                    return(RedirectToAction("Company_Entry"));
                }
            }
            else
            {
                try
                {
                    DataTable Checkdt = cbl.Check_Duplicate_CompanyCD(model.ComModel);
                    if (Checkdt.Rows.Count > 0)
                    {
                        DataTable dtIMsg  = cbl.Message_Select("1006", "I");
                        string    message = string.Empty;
                        if (dtIMsg.Rows.Count > 0)
                        {
                            // TempData["Imsg"] = dtIMsg.Rows[0]["Message1"].ToString();
                            TempData["Dmsg"] = "Duplicate CompanyCD is " + model.ComModel.CompanyCD;
                        }
                    }
                    else
                    {
                        var option = new TransactionOptions
                        {
                            IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted,
                            Timeout        = TimeSpan.MaxValue
                        };
                        TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, option);
                        using (scope)
                        {
                            string PcName = System.Environment.MachineName;

                            //Insert Company
                            if (model.ComModel.ZipCD1 != null)
                            {
                                string[] zips = model.ComModel.ZipCD1.Split(new Char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                                string   zip1 = zips[0].ToString();
                                string   zip2 = zips[1].ToString();

                                model.ComModel.ZipCD1 = zip1;
                                model.ComModel.ZipCD2 = zip2;
                            }

                            model.ComModel.InsertOperator = Session["CompanyCD"].ToString();
                            DataTable dt = cbl.InsertCompany(model.ComModel, PcName);

                            //Insert Company Shipping
                            Array arrayShip = model.ShippingModel.ToArray();

                            if (arrayShip.Length > 0)
                            {
                                for (int i = 0; i < arrayShip.Length; i++)
                                {
                                    if ((!string.IsNullOrWhiteSpace(model.ShippingModel[i].ShippingID.ToString())) && (!string.IsNullOrWhiteSpace(model.ComModel.CompanyCD.ToString())) && model.ShippingModel[i].ShippingID.ToString() != "0")
                                    {
                                        if (model.ShippingModel[i].ZipCD1 != null)
                                        {
                                            string[] zipships = model.ShippingModel[i].ZipCD1.Split(new Char[] { '-' }, StringSplitOptions.RemoveEmptyEntries);
                                            string   zipShip1 = zipships[0].ToString();
                                            string   zipShip2 = zipships[1].ToString();
                                            model.ShippingModel[i].ZipCD1 = zipShip1;
                                            model.ShippingModel[i].ZipCD2 = zipShip2;
                                        }

                                        model.ShippingModel[i].InsertOperator = Session["CompanyCD"].ToString();
                                        DataTable dtShip = cbl.InsertCompanyShipping(model.ShippingModel[i], model.ComModel, PcName);
                                    }
                                }
                            }

                            //Insert Company Tag

                            Array ArrayTag = model.TagModel.ToArray();

                            if (ArrayTag.Length > 0)
                            {
                                for (int i = 0; i < ArrayTag.Length; i++)
                                {
                                    if (model.TagModel[i].Tag != null && (!string.IsNullOrWhiteSpace(model.ComModel.CompanyCD.ToString())))
                                    {
                                        model.TagModel[i].InsertOperator = Session["CompanyCD"].ToString();

                                        DataTable dtTag = cbl.InsertCompanyTag(model.TagModel[i], model.ComModel, PcName);
                                    }
                                }
                            }

                            //Insert  Company  Brand
                            if (model.MBrandModel.BrandName != null)
                            {
                                model.MBrandModel.InsertOperator = Session["CompanyCD"].ToString();

                                DataTable dtBrand = cbl.InsertCompanyBrand(model.MBrandModel, model.ComModel, PcName);
                            }
                            scope.Complete();
                        }

                        TempData["Imsg"] = "success";
                    }
                    return(RedirectToAction("Company_Entry"));
                    //return RedirectToAction("CompanyUpdate_View");
                }
                catch (Exception ex)
                {
                    string st = ex.ToString();

                    TempData["Emsg"] = "Unsuccess";

                    return(RedirectToAction("Company_Entry"));
                }
            }
        }