Esempio n. 1
0
        public ActionResult Editdo(string sysflag, int?page, string orderdata, string orderdata1)
        {
            page               = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page       = page;
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qpdno = "", qallcomid = "", qvcno = "", qvcsdate = "", qvcedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qallcomid"]))
            {
                qallcomid       = Request["qallcomid"].Trim();
                ViewBag.qvendno = qallcomid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcno"]))
            {
                qvcno         = Request["qvcno"].Trim();
                ViewBag.qvcno = qvcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcsdate"]))
            {
                qvcsdate         = Request["qvcsdate"].Trim();
                ViewBag.qvcsdate = qvcsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcedate"]))
            {
                qvcedate         = Request["qvcedate"].Trim();
                ViewBag.qvcedate = qvcedate;
            }

            if (!string.IsNullOrWhiteSpace(Request["qpdno"]))
            {
                qpdno         = Request["qpdno"].Trim();
                ViewBag.qpdno = qpdno;
            }

            int vcid = int.Parse(Request["vcid"].ToString());

            Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();

            using (AitagBill_DBContext con = new AitagBill_DBContext())
            {
                vend_contract modobj = con.vend_contract.Where(r => r.vcid == vcid).FirstOrDefault();

                modobj.vcdate  = DateTime.Parse(Request["vcdate"].ToString());
                modobj.vcsdate = DateTime.Parse(Request["vcsdate"].ToString());
                modobj.vcedate = DateTime.Parse(Request["vcedate"].ToString());
                modobj.comid   = Request["comid"];
                modobj.projno  = Request["projno"];

                modobj.taxtype          = Request["taxtype"];
                modobj.vcmoney          = int.Parse(Request["vcmoney"]);
                modobj.vctaxmoney       = int.Parse(Request["vctaxmoney"]);
                modobj.vcallmoney       = int.Parse(Request["vcallmoney"]);
                modobj.vccomment        = Request["vccomment"];
                modobj.allcomid         = Request["allcomid"];
                modobj.bmodid           = Session["empid"].ToString();
                modobj.bmoddate         = DateTime.Now;
                con.Entry(modobj).State = EntityState.Modified;
                con.SaveChanges();
                con.Dispose();
            }
            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/custcontract/list' method='post'>";
            tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
            tmpform += "<input type=hidden id='qpdno' name='qpdno' value='" + qpdno + "'>";
            tmpform += "<input type=hidden id='qallcomid' name='qallcomid' value='" + qallcomid + "'>";
            tmpform += "<input type=hidden id='qvcno' name='qvcno' value='" + qvcno + "'>";
            //tmpform += "<input type=hidden id='qpcomment' name='qpcomment' value='" + qpcomment + "'>";
            tmpform += "<input type=hidden id='qvcsdate' name='qvcsdate' value='" + qvcsdate + "'>";
            tmpform += "<input type=hidden id='qvcedate' name='qvcedate' value='" + qvcedate + "'>";
            tmpform += "</form>";
            tmpform += "</body>";


            return(new ContentResult()
            {
                Content = @"" + tmpform
            });
        }
Esempio n. 2
0
        //[HttpPost]
        public ActionResult add(mediaclass col, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "mcno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qmcno = "", qmctitle = "";

            if (!string.IsNullOrWhiteSpace(Request["qmcno"]))
            {
                qmcno         = Request["qmcno"].Trim();
                ViewBag.qmcno = qmcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qmctitle"]))
            {
                qmctitle         = Request["qmctitle"].Trim();
                ViewBag.qmctitle = qmctitle;
            }

            if (sysflag != "A")
            {
                mediaclass newcol = new mediaclass();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    SqlConnection         conn  = dbobj.get_conn("AitagBill_DBContext");
                    SqlDataReader         dr;
                    SqlCommand            sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select mcno from mediaclass where mcno = '" + col.mcno + "'";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();

                    if (dr.Read())
                    {
                        ModelState.AddModelError("", "類別編號重複!");
                        return(View(col));
                    }
                    dr.Close();
                    dr.Dispose();
                    sqlsmd.Dispose();
                    conn.Close();
                    conn.Dispose();

                    col.comid    = Session["comid"].ToString();
                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.mediaclass.Add(col);
                        con.SaveChanges();

                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "類別編號:" + col.mcno + "類別名稱:" + col.mctitle;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================
                    }
                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/mediaclass/List' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qmcno' name='qmcno' value='" + qmcno + "'>";
                    tmpform += "<input type=hidden id='qmctitle' name='qmctitle' value='" + qmctitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                }
            }
        }
Esempio n. 3
0
        public ActionResult adddo(string sysflag, int?page, string orderdata, string orderdata1)
        {
            page               = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page       = page;
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qbseason = "", qslyear = "", qslmonth = "", qvtype = "", qvendcomid = "", qsdate = "", qedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qbseason"]))
            {
                qbseason         = Request["qbseason"].Trim();
                ViewBag.qbseason = qbseason;
            }
            if (!string.IsNullOrWhiteSpace(Request["qslyear"]))
            {
                qslyear         = Request["qslyear"].Trim();
                ViewBag.qslyear = qslyear;
            }
            if (!string.IsNullOrWhiteSpace(Request["qslmonth"]))
            {
                qslmonth         = Request["qslmonth"].Trim();
                ViewBag.qslmonth = qslmonth;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvtype"]))
            {
                qvtype         = Request["qvtype"].Trim();
                ViewBag.qvtype = qvtype;
            }

            if (!string.IsNullOrWhiteSpace(Request["qvendcomid"]))
            {
                qvendcomid         = Request["qvendcomid"].Trim();
                ViewBag.qvendcomid = qvendcomid;
            }


            if (!string.IsNullOrWhiteSpace(Request["qsdate"]))
            {
                qsdate         = Request["qsdate"].Trim();
                ViewBag.qsdate = qsdate;
            }


            if (!string.IsNullOrWhiteSpace(Request["qedate"]))
            {
                qedate         = Request["qedate"].Trim();
                ViewBag.qedate = qedate;
            }


            NDcommon dbobj = new NDcommon();

            SqlConnection erpconn  = dbobj.get_conn("AitagBill_DBContext");
            SqlConnection erpconn1 = dbobj.get_conn("AitagBill_DBContext");

            using (AitagBill_DBContext con = new AitagBill_DBContext())
            {
                string tmpssql = "";
                int    strym   = 0;
                int    etrym   = 0;
                //找審過過單
                tmpssql = "select (payvendcomid) as vendno, isnull(sum(psummoney),0) as psummoney FROM vend_contractinvclose INNER JOIN vend_contractinvclose_det ON vend_contractinvclose.vcinvid =vend_contractinvclose_det.vcinvid where vstatus<>'D' ";

                switch (qbseason)
                {
                case "01":    //月獎
                    tmpssql += " and slyear =" + qslyear + " and slmonth = " + qslmonth + "  group by payvendcomid ";
                    break;

                case "02":    //季獎 3 / 6 / 9/ 12
                    strym = 365 * int.Parse(qslyear) + 30 * int.Parse(qslmonth);
                    //etrym = qslyear.ToString() + qslmonth.ToString().PadLeft(2, '0');
                    if (qslmonth.ToString().PadLeft(2, '0') == "03")
                    {
                        strym = 365 * int.Parse(qslyear) + 30 * 1;
                        etrym = 365 * int.Parse(qslyear) + 30 * 3;
                    }
                    else if (qslmonth.ToString().PadLeft(2, '0') == "06")
                    {
                        strym = 365 * int.Parse(qslyear) + 30 * 4;
                        etrym = 365 * int.Parse(qslyear) + 30 * 6;
                    }
                    else if (qslmonth.ToString().PadLeft(2, '0') == "09")
                    {
                        strym = 365 * int.Parse(qslyear) + 30 * 7;
                        etrym = 365 * int.Parse(qslyear) + 30 * 9;
                    }
                    else if (qslmonth.ToString().PadLeft(2, '0') == "12")
                    {
                        strym = 365 * int.Parse(qslyear) + 30 * 10;
                        etrym = 365 * int.Parse(qslyear) + 30 * 12;
                    }
                    tmpssql += " and (slyear * 365 + slmonth * 30) >= " + strym.ToString() + " and (slyear * 365 + slmonth * 30)  <= " + etrym.ToString() + " group by payvendcomid ";
                    break;

                case "03":    //半年獎 06 / 12
                    strym = 365 * int.Parse(qslyear) + 30 * int.Parse(qslmonth);
                    //etrym = qslyear.ToString() + qslmonth.ToString().PadLeft(2, '0');
                    if (qslmonth.ToString().PadLeft(2, '0') == "06")
                    {
                        strym = 365 * int.Parse(qslyear) + 30 * 1;
                        etrym = 365 * int.Parse(qslyear) + 30 * 6;
                    }
                    else if (qslmonth.ToString().PadLeft(2, '0') == "12")
                    {
                        strym = 365 * int.Parse(qslyear) + 30 * 7;
                        etrym = 365 * int.Parse(qslyear) + 30 * 12;
                    }

                    tmpssql += " and (slyear * 365 + slmonth * 30) >= " + strym.ToString() + " and (slyear * 365 + slmonth * 30)  <= " + etrym.ToString() + " group by payvendcomid ";
                    break;

                case "04":    //年獎
                    tmpssql += " and year(vadate) =" + qslyear + " group by payvendcomid ";
                    break;
                }

                SqlDataReader dr    = dbobj.dbselect(erpconn, tmpssql);
                string        iftax = "";
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        decimal tmprate        = 0;
                        decimal tmppsummoney   = decimal.Parse(dr["psummoney"].ToString());
                        decimal pallbonusmoney = tmppsummoney;
                        // 找 廠商/客戶的 計算方式 , vendno 在客戶計算是客戶的欄位
                        //tmpssql = "select * from allcompany_rate where bseason='" + qbseason + "' and allcomid='" + dr["vendno"].ToString() + "' and (bsmoney <=" + tmppsummoney + " and  bemoney >=" + tmppsummoney + " )";
                        //單筆金額
                        tmpssql = "select * from allcompany_rate where bseason='" + qbseason + "' and allcomid='" + dr["vendno"].ToString() + "' and btype = '0'";
                        SqlDataReader dr1 = dbobj.dbselect(erpconn1, tmpssql);
                        if (dr1.Read())
                        {
                            pallbonusmoney = decimal.Parse(dr1["brate"].ToString());
                        }

                        dr1.Close();
                        dr1.Dispose();

                        //單筆比例
                        tmpssql = "select * from allcompany_rate where bseason='" + qbseason + "' and allcomid='" + dr["vendno"].ToString() + "' and btype = '1'";
                        dr1     = dbobj.dbselect(erpconn1, tmpssql);
                        if (dr1.Read())
                        {
                            iftax   = dr1["brate"].ToString();
                            tmprate = decimal.Parse(dr1["brate"].ToString());
                            if (iftax == "0")
                            {
                                pallbonusmoney = pallbonusmoney * tmprate / 100;
                            }
                            else
                            {
                                pallbonusmoney = (pallbonusmoney * tmprate * decimal.Parse("1.05")) / 100;
                            }
                        }

                        dr1.Close();
                        dr1.Dispose();

                        //落點金額比例
                        tmpssql = "select * from allcompany_rate where bseason='" + qbseason + "' and allcomid='" + dr["vendno"].ToString() + "' and btype = '2' and (bsmoney <=" + tmppsummoney + " and  bemoney >=" + tmppsummoney + ")";
                        dr1     = dbobj.dbselect(erpconn1, tmpssql);
                        if (dr1.Read())
                        {
                            iftax   = dr1["brate"].ToString();
                            tmprate = decimal.Parse(dr1["brate"].ToString());
                            if (iftax == "0")
                            {
                                pallbonusmoney = pallbonusmoney * tmprate / 100;
                            }
                            else
                            {
                                pallbonusmoney = (pallbonusmoney * tmprate * decimal.Parse("1.05")) / 100;
                            }
                        }

                        dr1.Close();
                        dr1.Dispose();

                        //累積金額比例
                        tmpssql = "select * from allcompany_rate where bseason='" + qbseason + "' and allcomid='" + dr["vendno"].ToString() + "' and btype = '3' and (bsmoney <=" + tmppsummoney + " and  bemoney >=" + tmppsummoney + ")";
                        dr1     = dbobj.dbselect(erpconn1, tmpssql);
                        if (dr1.Read())
                        {
                            iftax   = dr1["brate"].ToString();
                            tmprate = decimal.Parse(dr1["brate"].ToString());
                            if (iftax == "0")
                            {
                                pallbonusmoney = pallbonusmoney * tmprate / 100;
                            }
                            else
                            {
                                pallbonusmoney = (pallbonusmoney * tmprate * decimal.Parse("1.05")) / 100;
                            }
                        }

                        dr1.Close();
                        dr1.Dispose();

                        vend_monthmoney addobj = new vend_monthmoney();
                        addobj.bseason = qbseason; //01:月獎 02:季獎 03:半年獎 04:年獎  05:現折
                        addobj.slyear  = int.Parse(qslyear);
                        if (qbseason == "04")
                        {
                            addobj.slmonth = 12;
                        }
                        else
                        {
                            addobj.slmonth = int.Parse(qslmonth);
                        }

                        addobj.vendcomid      = dr["vendno"].ToString();
                        addobj.vtype          = "2";//1:收入 2:支出
                        addobj.pallbonusmoney = pallbonusmoney;
                        addobj.pallmoney      = tmppsummoney;

                        addobj.bmodid   = Session["empid"].ToString();
                        addobj.bmoddate = DateTime.Now;
                        addobj.comid    = Session["comid"].ToString();
                        con.vend_monthmoney.Add(addobj);
                    }
                }


                con.SaveChanges();
                con.Dispose();
            }

            erpconn.Close();
            erpconn.Dispose();

            erpconn1.Close();
            erpconn1.Dispose();
            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/vend_monthmoney/list' method='post'>";
            tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
            tmpform += "<input type=hidden id='qbseason' name='qbseason' value='" + qbseason + "'>";
            tmpform += "<input type=hidden id='qslyear' name='qslyear' value='" + qslyear + "'>";
            tmpform += "<input type=hidden id='qslmonth' name='qslmonth' value='" + qslmonth + "'>";
            tmpform += "<input type=hidden id='qvendcomid' name='qvendcomid' value='" + qvendcomid + "'>";

            tmpform += "</form>";
            tmpform += "</body>";


            return(new ContentResult()
            {
                Content = @"" + tmpform
            });
        }
Esempio n. 4
0
        public ActionResult detlistdo(string sysflag, int?page, string orderdata, string orderdata1)
        {
            NDcommon      dbobj = new NDcommon();
            SqlConnection erpconn = dbobj.get_conn("AitagBill_DBContext");
            SqlCommand    cmd = new SqlCommand();
            string        wno = "", comid = "";

            using (AitagBill_DBContext con = new AitagBill_DBContext())
            {
                page               = ((!page.HasValue || page < 1) ? 1 : page);
                ViewBag.page       = page;
                ViewBag.orderdata  = orderdata;
                ViewBag.orderdata1 = orderdata1;
                string sqlstr = "";

                string cdel1     = Request["wkdid"];
                string wkcdate1  = Request["wkcdate"];
                string wkstep1   = Request["wkstep"];
                string getman1   = Request["getman"];
                string prdate1   = Request["prdate"];
                string realdate1 = Request["realdate"];
                string worktype1 = Request["worktype"];
                string makeitem1 = Request["makeitem"];

                string[] cdelarr     = cdel1.Split(',');
                string[] wkcdatedarr = wkcdate1.Split(',');
                string[] wksteparr   = wkstep1.Split(',');
                string[] getmanarr   = getman1.Split(',');
                string[] prdatearr   = prdate1.Split(',');
                string[] realdatearr = realdate1.Split(',');
                string[] worktypearr = worktype1.Split(',');
                string[] makeitemrr  = makeitem1.Split(',');

                wno   = Request["wno"].ToString();
                comid = Request["comid"].ToString();

                for (int i = 0; i < cdelarr.Length; i++)
                {
                    if (cdelarr[i].Trim() == "")
                    {
                        if (!(wkcdatedarr[i].Trim() == "" && wksteparr[i].Trim() == ""))
                        {
                            workcard_det addobj = new workcard_det();
                            addobj.comid   = comid;
                            addobj.wno     = wno;
                            addobj.wkcdate = DateTime.Parse(wkcdatedarr[i].ToString());
                            addobj.wkstep  = wksteparr[i].Trim();
                            addobj.getman  = getmanarr[i].Trim();


                            addobj.bmodid   = Session["empid"].ToString();
                            addobj.bmoddate = DateTime.Now;
                            if (prdatearr[i].ToString() != "")
                            {
                                addobj.prdate = DateTime.Parse(prdatearr[i].ToString());
                            }
                            else
                            {
                                addobj.prdate = null;
                            }
                            if (realdatearr[i].ToString() != "")
                            {
                                addobj.realdate = DateTime.Parse(realdatearr[i].ToString());
                            }
                            else
                            {
                                addobj.realdate = null;
                            }
                            addobj.worktype = worktypearr[i].Trim();
                            addobj.makeitem = makeitemrr[i].Trim();


                            con.workcard_det.Add(addobj);
                            con.SaveChanges();
                        }
                    }
                    else
                    {
                        //修改
                        int          wkdid  = int.Parse(cdelarr[i].Trim());
                        workcard_det modobj = con.workcard_det.Where(r => r.wkdid == wkdid).FirstOrDefault();



                        modobj.wkcdate = DateTime.Parse(wkcdatedarr[i].ToString());
                        modobj.wkstep  = wksteparr[i].Trim();
                        modobj.getman  = getmanarr[i].Trim();

                        if (prdatearr[i].ToString() != "")
                        {
                            modobj.prdate = DateTime.Parse(prdatearr[i].ToString());
                        }
                        else
                        {
                            modobj.prdate = null;
                        }
                        if (realdatearr[i].ToString() != "")
                        {
                            modobj.realdate = DateTime.Parse(realdatearr[i].ToString());
                        }
                        else
                        {
                            modobj.realdate = null;
                        }
                        modobj.worktype = worktypearr[i].Trim();
                        modobj.makeitem = makeitemrr[i].Trim();


                        modobj.bmodid   = Session["empid"].ToString();
                        modobj.bmoddate = DateTime.Now;


                        con.Entry(modobj).State = EntityState.Modified;
                        con.SaveChanges();
                    }
                }
                con.Dispose();
            }

            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/workcard/detlist' method='post'>";
            tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
            tmpform += "<input type=hidden name='wno' id='wno' value='" + wno + "'>";
            tmpform += "<input type=hidden name='comid' id='comid' value='" + comid + "'>";
            tmpform += "</body>";

            erpconn.Close();
            erpconn.Dispose();

            return(new ContentResult()
            {
                Content = @"" + tmpform
            });
        }
Esempio n. 5
0
        public ActionResult Edit(mediaclass chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "mcno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qmcno = "", qmctitle = "";

            if (!string.IsNullOrWhiteSpace(Request["qmcno"]))
            {
                qmcno         = Request["qmcno"].Trim();
                ViewBag.qmcno = qmcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qmctitle"]))
            {
                qmctitle         = Request["qmctitle"].Trim();
                ViewBag.qmctitle = qmctitle;
            }

            if (sysflag != "E")
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    var        data          = con.mediaclass.Where(r => r.mcno == chks.mcno).FirstOrDefault();
                    mediaclass ebillsubjects = con.mediaclass.Find(chks.mcno);
                    if (ebillsubjects == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(ebillsubjects));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        NDcommon dbobj = new NDcommon();
                        chks.bmodid           = Session["tempid"].ToString();
                        chks.bmoddate         = DateTime.Now;
                        con.Entry(chks).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "編號:" + chks.mcno + "名稱:" + chks.mctitle;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=qfr1.submit();>";
                        tmpform += "<form name='qfr1' action='/mediaclass/List' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                        tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                        tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                        tmpform += "<input type=hidden id='qmcno' name='qmcno' value='" + qmcno + "'>";
                        tmpform += "<input type=hidden id='qmctitle' name='qmctitle' value='" + qmctitle + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
Esempio n. 6
0
        public ActionResult Edit(workcard chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = " wno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = " asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qwno = "", qcustno = "";

            if (!string.IsNullOrWhiteSpace(Request["qwno"]))
            {
                qwno         = Request["qwno"].Trim();
                ViewBag.qwno = qwno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcustno"]))
            {
                qcustno         = Request["qcustno"].Trim();
                ViewBag.qcustno = qcustno;
            }
            if (sysflag != "E")
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    var      data      = con.workcard.Where(r => r.wno == chks.wno && r.comid == chks.comid).FirstOrDefault();
                    workcard eCompanys = con.workcard.Find(chks.wno);
                    if (eCompanys == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(eCompanys));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    NDcommon dbobj = new NDcommon();

                    string wno   = Request["wno"].ToString();
                    string comid = Request["comid"].ToString();

                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        workcard modobj = con.workcard.Where(r => r.wno == wno && r.comid == comid).FirstOrDefault();


                        modobj.projno  = Request["projno"];
                        modobj.custno  = Request["custno"];
                        modobj.wktitle = Request["wktitle"];

                        modobj.wkbudget = int.Parse(Request["wkbudget"]);

                        modobj.prodno = Request["prodno"];
                        modobj.pwno   = Request["pwno"];
                        modobj.ifwh   = Request["ifwh"];
                        modobj.whno   = Request["whno"];

                        modobj.prclosedate = DateTime.Parse(Request["prclosedate"].ToString());
                        modobj.putoffday   = int.Parse(Request["putoffday"]);
                        modobj.closedate   = DateTime.Parse(Request["closedate"].ToString());
                        modobj.closeman    = Request["closeman"];
                        modobj.slyear      = int.Parse(Request["slyear"]);
                        modobj.slmonth     = int.Parse(Request["slmonth"]);
                        modobj.tkyear      = int.Parse(Request["tkyear"]);
                        modobj.tkmonth     = int.Parse(Request["tkmonth"]);


                        modobj.bmodid           = Session["empid"].ToString();
                        modobj.bmoddate         = DateTime.Now;
                        con.Entry(modobj).State = EntityState.Modified;
                        con.SaveChanges();
                        con.Dispose();
                    }

                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysnote    = "客戶:" + Request["custno"] + "工作卡號:" + wno;
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/workcard/list' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qwno' name='qwno' value='" + qwno + "'>";
                    tmpform += "<input type=hidden id='qcustno' name='qcustno' value='" + qcustno + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('修改成功!!');</script>" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Esempio n. 7
0
        public ActionResult add(workcard col, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = " wno";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = " asc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qwno = "", qcustno = "";

            if (!string.IsNullOrWhiteSpace(Request["qwno"]))
            {
                qwno         = Request["qwno"].Trim();
                ViewBag.qwno = qwno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcustno"]))
            {
                qcustno         = Request["qcustno"].Trim();
                ViewBag.qcustno = qcustno;
            }

            NDcommon dbobj = new NDcommon();



            if (sysflag != "A")
            {
                workcard newcol = new workcard();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    SqlConnection conn = dbobj.get_conn("AitagBill_DBContext");
                    col.wno = dbobj.get_billno(conn, "W", "", col.comid.ToString(), "", col.adddate.ToString());
                    conn.Close();
                    conn.Dispose();
                    col.wstatus  = "0";
                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;
                    col.ownman   = Session["empid"].ToString();
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.workcard.Add(col);
                        con.SaveChanges();
                    }

                    //系統LOG檔 //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    string        sysnote    = "客戶:" + col.custno + "工作卡號:" + col.wno;
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/workcard/list' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qwno' name='qwno' value='" + qwno + "'>";
                    tmpform += "<input type=hidden id='qcustno' name='qcustno' value='" + qcustno + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";
                    return(new ContentResult()
                    {
                        Content = @"<script>alert('新增成功!!');</script>" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Esempio n. 8
0
        public ActionResult brlistdo(string sysflag, int?page, string orderdata, string orderdata1)
        {
            string vcid = "";

            using (AitagBill_DBContext con = new AitagBill_DBContext())
            {
                page               = ((!page.HasValue || page < 1) ? 1 : page);
                ViewBag.page       = page;
                ViewBag.orderdata  = orderdata;
                ViewBag.orderdata1 = orderdata1;
                string sqlstr = "";
                string cdel1  = Request["bid"];

                string bseason1 = Request["bseason"];
                string btype1   = Request["btype"];
                //string mdno1 = Request["mdno"];
                //string mdcomment1 = Request["mdcomment"];
                string bsmoney1  = Request["bsmoney"];
                string bemoney1  = Request["bemoney"];
                string brate1    = Request["brate"];
                string bcomment1 = Request["bcomment"];

                string[] cdelarr    = cdel1.Split(',');
                string[] bseasonarr = bseason1.Split(',');
                string[] btypearr   = btype1.Split(',');
                // string[] mdnoarr = mdno1.Split(',');
                // string[] mdcommentarr = mdcomment1.Split(',');
                string[] bsmoneyarr  = bsmoney1.Split(',');
                string[] bemoneyarr  = bemoney1.Split(',');
                string[] bratearr    = brate1.Split(',');
                string[] bcommentarr = bcomment1.Split(',');


                vcid = Request["vcid"].ToString();
                int pitemno = 10;
                for (int i = 0; i < cdelarr.Length; i++)
                {
                    if (cdelarr[i].Trim() == "")
                    {
                        if (!(bseasonarr[i].Trim() == ""))
                        {
                            bonusrate addobj = new bonusrate();
                            addobj.vcid = int.Parse(vcid);
                            //addobj.vcno = Request["vcno"].ToString();
                            addobj.comid = Request["comid"].ToString();

                            addobj.bseason = bseasonarr[i].Trim();
                            addobj.btype   = btypearr[i].Trim();
                            // addobj.mdno = mdnoarr[i].Trim();
                            // addobj.mdcomment = mdcommentarr[i].Trim();

                            // addobj.vitemno = pitemno;
                            addobj.bsmoney = int.Parse(bsmoneyarr[i].ToString());
                            addobj.bemoney = int.Parse(bemoneyarr[i].ToString());
                            addobj.brate   = Decimal.Parse(bratearr[i].ToString());
                            //addobj.vcallmoney = Decimal.Parse(vcallmoneyarr[i].ToString());

                            addobj.bcomment = bcommentarr[i].Trim();
                            // addobj.projno = Request["projno"].ToString();

                            addobj.bmodid   = Session["empid"].ToString();
                            addobj.bmoddate = DateTime.Now;

                            con.bonusrate.Add(addobj);
                            con.SaveChanges();
                            pitemno = pitemno + 10;
                        }
                    }
                    else
                    {
                        //修改
                        int       bid    = int.Parse(cdelarr[i].Trim());
                        bonusrate modobj = con.bonusrate.Where(r => r.bid == bid).FirstOrDefault();


                        modobj.comid = Request["comid"].ToString();

                        modobj.bseason = bseasonarr[i].Trim();
                        modobj.btype   = btypearr[i].Trim();
                        // addobj.mdno = mdnoarr[i].Trim();
                        // addobj.mdcomment = mdcommentarr[i].Trim();

                        // addobj.vitemno = pitemno;
                        modobj.bsmoney = int.Parse(bsmoneyarr[i].ToString());
                        modobj.bemoney = int.Parse(bemoneyarr[i].ToString());
                        modobj.brate   = Decimal.Parse(bratearr[i].ToString());
                        //addobj.vcallmoney = Decimal.Parse(vcallmoneyarr[i].ToString());

                        modobj.bcomment = bcommentarr[i].Trim();
                        // addobj.projno = Request["projno"].ToString();

                        modobj.bmodid   = Session["empid"].ToString();
                        modobj.bmoddate = DateTime.Now;
                        modobj.bmodid   = Session["empid"].ToString();
                        modobj.bmoddate = DateTime.Now;

                        con.Entry(modobj).State = EntityState.Modified;
                        con.SaveChanges();
                    }
                }
                con.Dispose();
            }

            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/custcontract/brlist' method='post'>";
            tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
            tmpform += "<input type=hidden name='vcid' id='vcid' value='" + vcid + "'>";
            tmpform += "</form>";
            tmpform += "</body>";



            return(new ContentResult()
            {
                Content = @"" + tmpform
            });
        }
Esempio n. 9
0
        public ActionResult Transfer(string sysflag, vend_contractdet col, HttpPostedFileBase upfile)
        {
            ViewBag.vcid = Request["vcid"].ToString();

            if (sysflag != "A")
            {
                return(View());
            }
            else
            {
                Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                if (upfile != null)
                {
                    String sernonum = "";
                    //重新命名,存入檔案
                    DateTime myDate = DateTime.Now;
                    sernonum = myDate.ToString("yyyyMMddHHmmss");
                    string BasicPath  = Server.MapPath("~/upload/");
                    int    inputcount = 0;
                    string fileName   = upfile.FileName.Substring(upfile.FileName.IndexOf("."), upfile.FileName.Length - upfile.FileName.IndexOf("."));

                    if (fileName != ".exe" && fileName != ".asp" && fileName != ".aspx" && fileName != ".jsp" && fileName != ".php")
                    {
                        fileName = "cust-" + sernonum.ToString() + fileName;
                        upfile.SaveAs(Server.MapPath("~/upload/") + fileName);

                        string tmppath = BasicPath + fileName;


                        StreamReader sr     = new StreamReader(@tmppath, System.Text.Encoding.Default);
                        string       allstr = sr.ReadToEnd(); //從資料流末端存取檔案
                        sr.Close();

                        string[] tmpstridno;       //匯入資料
                        string[] toptmparry;       //匯入的第一筆資料(欄位)
                        int      tmparrycount = 0; //匯入欄位數
                        tmpstridno = allstr.Split(System.Environment.NewLine.ToCharArray());

                        //找第一筆的欄位數
                        toptmparry = tmpstridno[0].Split(',');

                        for (int tmpi = 0; tmpi <= toptmparry.Length - 1; tmpi++)
                        {
                            if (toptmparry[tmpi] != "")
                            {
                                tmparrycount++;
                            }
                        }

                        SqlConnection conn = dbobj.get_conn("Aitag_DBContext");
                        string[]      tmparry;
                        int           vitemno = 0;
                        for (int i = 1; i <= tmpstridno.Length - 1; i++)
                        {
                            if (tmpstridno[i] != "")
                            {
                                #region

                                inputcount++;
                                tmparry = tmpstridno[i].Split(',');
                                //判斷必填欄位
                                if (tmparry[0] != "" && tmparry[1] != "")
                                {
                                    // 品項編號0	品項名稱1	單位2	數量3	單價4	金額5	備註6
                                    vitemno         = vitemno + 2;
                                    col.vcid        = int.Parse(ViewBag.vcid);
                                    col.bdprodno    = tmparry[0];
                                    col.bdprodtitle = tmparry[1];
                                    col.vitemno     = vitemno;
                                    col.pdunit      = tmparry[2];
                                    col.vccount     = int.Parse(tmparry[3]);
                                    col.vcmoney     = int.Parse(tmparry[4]);
                                    col.vcallmoney  = int.Parse(tmparry[5]);
                                    col.vcdcomment  = tmparry[6];

                                    col.comid    = Session["comid"].ToString();
                                    col.bmodid   = Session["tempid"].ToString();
                                    col.bmoddate = DateTime.Now;
                                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                                    {
                                        con.vend_contractdet.Add(col);
                                        con.SaveChanges();
                                        //系統LOG檔 //================================================= //
                                        //SqlConnection sysconn = dbobj.get_conn("MatsuEip_DBContext");
                                        //string sysrealsid = Request["sysrealsid"].ToString();
                                        //string syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                                        //string sysnote = "行事曆標題:" + col.wstitle + "<br>日期:" + col.wsdate + "的資料";
                                        //dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                                        //sysconn.Close();
                                        //sysconn.Dispose();
                                        //=================================================
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                    else
                    {
                        ViewBag.AddModelError = @"alert('上傳格式錯誤!');";
                        return(View());
                    }
                }

                ViewBag.AddModel = @"alert('轉檔成功!');" +
                                   @"parent.opener.location.href = '/custcontract/detlist?vcid=" + ViewBag.vcid + "&sid=" + Request["sid"].ToString() + "&realsid=" + Request["realsid"].ToString() + "';" +
                                   @"window.close();";


                return(View());
            }
        }
Esempio n. 10
0
        public ActionResult adddo(string sysflag, int?page, string orderdata, string orderdata1)
        {
            page               = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page       = page;
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;

            string qpdno = "", qallcomid = "", qvcno = "", qvcsdate = "", qvcedate = "";

            if (!string.IsNullOrWhiteSpace(Request["qallcomid"]))
            {
                qallcomid       = Request["qallcomid"].Trim();
                ViewBag.qvendno = qallcomid;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcno"]))
            {
                qvcno         = Request["qvcno"].Trim();
                ViewBag.qvcno = qvcno;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcsdate"]))
            {
                qvcsdate         = Request["qvcsdate"].Trim();
                ViewBag.qvcsdate = qvcsdate;
            }
            if (!string.IsNullOrWhiteSpace(Request["qvcedate"]))
            {
                qvcedate         = Request["qvcedate"].Trim();
                ViewBag.qvcedate = qvcedate;
            }

            if (!string.IsNullOrWhiteSpace(Request["qpdno"]))
            {
                qpdno         = Request["qpdno"].Trim();
                ViewBag.qpdno = qpdno;
            }


            NDcommon      dbobj = new NDcommon();
            SqlConnection conn  = dbobj.get_conn("AitagBill_DBContext");
            string        vcno  = "";

            using (AitagBill_DBContext con = new AitagBill_DBContext())
            {
                vend_contract addobj = new vend_contract();
                vcno            = dbobj.get_billno(conn, "C", "", Request["comid"].ToString(), "", Request["pdate"].ToString());
                addobj.vcid     = Decimal.Parse(DateTime.Now.ToString("yyyyMMddhhmmssff"));
                addobj.vcdate   = DateTime.Parse(Request["pdate"].ToString());
                addobj.comid    = Request["comid"];
                addobj.vcno     = vcno;
                addobj.projno   = vcno;
                addobj.vcstatus = "0";
                addobj.vendtype = "2";
                addobj.taxtype  = Request["taxtype"];
                addobj.ownman   = Session["empid"].ToString();

                addobj.vcmoney    = int.Parse(Request["vcmoney"]);
                addobj.vctaxmoney = int.Parse(Request["vctaxmoney"]);
                addobj.vcallmoney = int.Parse(Request["vcallmoney"]);

                addobj.allcomid  = Request["allcomid"].Trim();
                addobj.vccomment = Request["vccomment"].Trim();

                addobj.bmodid   = Session["empid"].ToString();
                addobj.bmoddate = DateTime.Now;

                con.vend_contract.Add(addobj);

                con.SaveChanges();
                con.Dispose();
            }

            conn.Close();
            conn.Dispose();

            string tmpform = "";

            tmpform  = "<body onload=qfr1.submit();>";
            tmpform += "<form name='qfr1' action='/custcontract/list' method='post'>";
            tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
            tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
            tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
            tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
            tmpform += "<input type=hidden id='qpdno' name='qpdno' value='" + qpdno + "'>";
            tmpform += "<input type=hidden id='qallcomid' name='qallcomid' value='" + qallcomid + "'>";
            tmpform += "<input type=hidden id='qvcno' name='qvcno' value='" + qvcno + "'>";
            // tmpform += "<input type=hidden id='qpcomment' name='qpcomment' value='" + qpcomment + "'>";
            tmpform += "<input type=hidden id='qvcsdate' name='qvcsdate' value='" + qvcsdate + "'>";
            tmpform += "<input type=hidden id='qvcedate' name='qvcedate' value='" + qvcedate + "'>";
            tmpform += "</form>";
            tmpform += "</body>";


            return(new ContentResult()
            {
                Content = @"" + tmpform
            });
        }
Esempio n. 11
0
        public ActionResult chkEdit(sales_competition chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "ccid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qprodtitle = "", qcusttitlename = "";

            if (!string.IsNullOrWhiteSpace(Request["qprodtitle"]))
            {
                qprodtitle         = Request["qprodtitle"].Trim();
                ViewBag.qprodtitle = qprodtitle;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcusttitlename"]))
            {
                qcusttitlename     = Request["qcusttitlename"].Trim();
                ViewBag.qprodtitle = qcusttitlename;
            }

            if (sysflag != "E")
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    var data = con.sales_competition.Where(r => r.ccid == chks.ccid).FirstOrDefault();

                    sales_competition competitionlogs = con.sales_competition.Find(chks.ccid);
                    if (competitionlogs == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(competitionlogs));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldmsid = Request["oldmsid"];



                    NDcommon          dbobj = new NDcommon();
                    sales_competition col   = new sales_competition();
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        col = con.sales_competition.Find(chks.ccid);
                    }

                    string sysnote = "";
                    if (dbobj.get_dbnull2(Request["slogstatus"]) == "1")
                    {
                        string tmprolestampid = col.rolestampid;
                        string rolea_1        = col.rolestampidall;
                        string roleall        = rolea_1 + "," + tmprolestampid; //'簽核過角色(多個)
                        string billflowid     = col.billflowid.ToString();

                        //找出下一個角色是誰
                        string tmprole = dbobj.getnewcheck1("G", tmprolestampid, roleall, "", "", billflowid);

                        if (tmprole == "'topman'")
                        {
                            tmprole = "";
                        }
                        string slogstatus = "";
                        if (tmprole == "")
                        {
                            slogstatus = "1";// '己簽核
                        }
                        else
                        {
                            slogstatus = "0";
                            //'找往上呈核長管級數
                            //'==========================
                            string tmpflowlevel = "";
                            using (SqlConnection conn = dbobj.get_conn("Aitag_DBContext"))
                            {
                                tmpflowlevel = dbobj.get_dbvalue(conn, "select billflow from flowlevel where bid=" + billflowid);
                            }
                            if (tmpflowlevel == "")
                            {
                                tmpflowlevel = "0";
                            }
                            string[] tmpa      = rolea_1.Split(',');
                            int      tmpacount = tmpa.Length;
                            if (int.Parse(tmpflowlevel) == (tmpacount + 1))
                            {
                                tmprole    = "";
                                slogstatus = "1"; // '己簽核
                            }
                            //'==========================
                        }

                        col.slogstatus     = slogstatus;
                        col.rolestampid    = tmprole;
                        col.rolestampidall = roleall;
                        col.empstampidall  = col.empstampidall + ",'" + (string)Session["empid"] + "'"; //'所有人員帳號
                        col.bmodid         = (string)Session["empid"];
                        col.bmoddate       = DateTime.Now;
                        col.billtime       = col.billtime + "," + DateTime.Now.ToString();
                        col.lawcomment     = Request["lawcomment"].ToString();
                        col.fincomment     = Request["fincomment"].ToString();
                        if (tmprole != "")
                        {
                            //寄信
                            //holidaycheckmainEditMail(col, tmprole);
                        }
                        else
                        {
                            //沒有下一個承辦人  (己通過)
                            ////資料通過後 搬移到cardreallog
                            //battacheckmainEditMove(col);

                            //(己通過)  寄信
                            //holidaycheckmainEditMailPass(col);
                        }
                        sysnote = "請假單審核通過作業";
                    }
                    else
                    {
                        col.slogstatus = "2";
                        col.rback      = Request["hback1"].ToString();
                        col.bmodid     = (string)Session["empid"];
                        col.bmoddate   = DateTime.Now;
                        col.billtime   = col.billtime + "," + DateTime.Now.ToString();

                        ////資料通過後 搬移到cardreallog
                        //battacheckmainEditMove(col);

                        //(己通過)  寄信
                        //holidaycheckmainEditMailBack(col);
                        sysnote = "新業務及競業退回作業";
                    }

                    col.bmodid   = Session["tempid"].ToString();
                    col.bmoddate = DateTime.Now;

                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.Entry(col).State = EntityState.Modified;
                        con.SaveChanges();
                    }



                    //系統LOG檔
                    //================================================= //
                    SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                    string        sysrealsid = Request["sysrealsid"].ToString();
                    string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                    //string sysnote = "承辦人:" + chks.empid + "產品名稱:" + chks.prodtitle;
                    dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                    sysconn.Close();
                    sysconn.Dispose();
                    //=================================================

                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/sales_competition/chk' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qprodtitle' name='qprodtitle' value='" + qprodtitle + "'>";
                    tmpform += "<input type=hidden id='qcusttitlename' name='qcusttitlename' value='" + qcusttitlename + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    //return RedirectToAction("List");
                }
            }
        }
Esempio n. 12
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    sales_competition col = new sales_competition();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(sales_competition col, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "ccid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qprodtitle = "", qcusttitle = "";

            if (!string.IsNullOrWhiteSpace(Request["qprodtitle"]))
            {
                qprodtitle         = Request["qprodtitle"].Trim();
                ViewBag.qprodtitle = qprodtitle;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcusttitle"]))
            {
                qcusttitle         = Request["qcusttitle"].Trim();
                ViewBag.qcusttitle = qcusttitle;
            }

            if (sysflag != "A")
            {
                sales_competition newcol = new sales_competition();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    SqlConnection         conn  = dbobj.get_conn("AitagBill_DBContext");
                    SqlDataReader         dr;
                    SqlCommand            sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select * from sales_competition where 1<>1";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();

                    if (dr.Read())
                    {
                        ModelState.AddModelError("", "簡易代碼重複!");
                        return(View(col));
                    }
                    dr.Close();
                    dr.Dispose();
                    sqlsmd.Dispose();
                    conn.Close();
                    conn.Dispose();

                    //找出下一個呈核角色
                    #region 找出下一個呈核角色
                    string tmparolestampid = "";
                    string tmprole         = "";
                    string tmpbillid       = "";
                    if (Request["arolestampid"].ToString() != "")
                    {
                        tmparolestampid = "'" + Request["arolestampid"].ToString() + "'";
                    }

                    string impallstring = dbobj.getnewcheck1("G", tmparolestampid, tmparolestampid, "1", "1", "");
                    tmprole   = impallstring.Split(';')[0].ToString();
                    tmpbillid = impallstring.Split(';')[1].ToString();
                    if (tmprole == "")
                    {
                        ViewBag.ErrMsg = @"<script>alert(""請先至表單流程設定中設定新業務及競業呈核流程!"");</script>";
                        return(View(col));
                    }
                    #endregion

                    col.custlevel1 = Request["custlevel1"];
                    col.custlevel2 = Request["custlevel2"];
                    col.custlevel3 = Request["custlevel3"];
                    col.iflaw      = "";
                    col.iffin      = "";
                    col.corpitem   = Request["corpitem"];
                    if (!string.IsNullOrWhiteSpace(Request["arolestampid"]))
                    {
                        col.arolestampid = Request["arolestampid"];
                    }
                    else
                    {
                        col.arolestampid = Request["arolestampid1"];
                    }

                    col.slogtype       = "1";
                    col.slogstatus     = "0"; // 己簽核:1  :0
                    col.rolestampid    = tmprole;
                    col.rolestampidall = tmparolestampid;
                    col.empstampidall  = "'" + col.empid + "'";
                    col.billflowid     = int.Parse(tmpbillid);
                    col.billtime       = DateTime.Now.ToString();
                    col.ccid           = Decimal.Parse(DateTime.Now.ToString("yyyyMMddhhmmssff"));
                    col.bmodid         = Session["tempid"].ToString();
                    col.bmoddate       = DateTime.Now;
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.sales_competition.Add(col);
                        con.SaveChanges();

                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "承辦人:" + col.empid + "產品名稱:" + col.prodtitle;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================
                    }
                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/sales_competition/List' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qcusttitle' name='qcusttitle' value='" + qcusttitle + "'>";
                    tmpform += "<input type=hidden id='qprodtitle' name='qprodtitle' value='" + qprodtitle + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }
Esempio n. 13
0
        public ActionResult Edit(sales_competition chks, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "ccid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qprodtitle = "", qcusttitlename = "";

            if (!string.IsNullOrWhiteSpace(Request["qprodtitle"]))
            {
                qprodtitle         = Request["qprodtitle"].Trim();
                ViewBag.qprodtitle = qprodtitle;
            }
            if (!string.IsNullOrWhiteSpace(Request["qcusttitlename"]))
            {
                qcusttitlename     = Request["qcusttitlename"].Trim();
                ViewBag.qprodtitle = qcusttitlename;
            }

            if (sysflag != "E")
            {
                using (AitagBill_DBContext con = new AitagBill_DBContext())
                {
                    var data = con.sales_competition.Where(r => r.ccid == chks.ccid).FirstOrDefault();


                    if (data == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(data));
                }
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(chks));
                }
                else
                {
                    //string oldmsid = Request["oldmsid"];


                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        var chdata = con.sales_competition.Where(r => r.ccid == chks.ccid).FirstOrDefault();

                        NDcommon dbobj = new NDcommon();
                        chdata.indclass         = Request["indclass"];
                        chdata.prodtitle        = Request["prodtitle"];
                        chdata.custtitle        = Request["custtitle"];
                        chdata.custlevel1       = Request["custlevel1"];
                        chdata.custlevel2       = Request["custlevel2"];
                        chdata.custlevel3       = Request["custlevel3"];
                        chdata.corpitem         = Request["corpitem"];
                        chdata.getcomtitle      = Request["getcomtitle"];
                        chdata.ifget            = Request["ifget"];
                        chdata.bmodid           = Session["tempid"].ToString();
                        chdata.bmoddate         = DateTime.Now;
                        con.Entry(chdata).State = EntityState.Modified;
                        con.SaveChanges();


                        //系統LOG檔
                        //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "承辦人:" + chks.empid + "產品名稱:" + chks.prodtitle;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================

                        string tmpform = "";
                        tmpform  = "<body onload=qfr1.submit();>";
                        tmpform += "<form name='qfr1' action='/sales_competition/List' method='post'>";
                        tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                        tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                        tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                        tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                        tmpform += "<input type=hidden id='qprodtitle' name='qprodtitle' value='" + qprodtitle + "'>";
                        tmpform += "<input type=hidden id='qcusttitlename' name='qcusttitlename' value='" + qcusttitlename + "'>";
                        tmpform += "</form>";
                        tmpform += "</body>";


                        return(new ContentResult()
                        {
                            Content = @"" + tmpform
                        });
                        //return RedirectToAction("List");
                    }
                }
            }
        }
Esempio n. 14
0
        //[HttpGet]
        //public ActionResult Add()
        //{
        //    ViewBag.Ifboss = Session["Ifboss"].ToString();
        //    ViewBag.Msid = Session["Msid"].ToString();
        //    billsubject col = new billsubject();
        //    return View(col);
        //}

        //[HttpPost]
        public ActionResult add(billsubject col, string sysflag, int?page, string orderdata, string orderdata1)
        {
            ModelState.Clear();
            page         = ((!page.HasValue || page < 1) ? 1 : page);
            ViewBag.page = page;
            if (string.IsNullOrWhiteSpace(orderdata))
            {
                orderdata = "accid";
            }

            if (string.IsNullOrWhiteSpace(orderdata1))
            {
                orderdata1 = "desc";
            }
            ViewBag.orderdata  = orderdata;
            ViewBag.orderdata1 = orderdata1;
            string qcomclass = "", qitemcode = "", qsubjecttitle = "";

            if (!string.IsNullOrWhiteSpace(Request["qcomclass"]))
            {
                qcomclass         = Request["qcomclass"].Trim();
                ViewBag.qcomclass = qcomclass;
            }
            if (!string.IsNullOrWhiteSpace(Request["qitemcode"]))
            {
                qitemcode         = Request["qitemcode"].Trim();
                ViewBag.qitemcode = qitemcode;
            }
            if (!string.IsNullOrWhiteSpace(Request["qsubjecttitle"]))
            {
                qsubjecttitle         = Request["qsubjecttitle"].Trim();
                ViewBag.qsubjecttitle = qsubjecttitle;
            }

            if (sysflag != "A")
            {
                billsubject newcol = new billsubject();
                return(View(newcol));
            }
            else
            {
                if (!ModelState.IsValid)
                {
                    return(View(col));
                }
                else
                {
                    Aitag.Models.NDcommon dbobj = new Aitag.Models.NDcommon();
                    SqlConnection         conn  = dbobj.get_conn("AitagBill_DBContext");
                    SqlDataReader         dr;
                    SqlCommand            sqlsmd = new SqlCommand();
                    sqlsmd.Connection = conn;
                    string sqlstr = "select accid from billsubject where comid = '" + Session["comid"] + "' and itemcode = '" + col.itemcode + "'";
                    sqlsmd.CommandText = sqlstr;
                    dr = sqlsmd.ExecuteReader();

                    if (dr.Read())
                    {
                        ModelState.AddModelError("", "歸帳代碼重複!");
                        return(View(col));
                    }
                    dr.Close();
                    dr.Dispose();
                    sqlsmd.Dispose();
                    conn.Close();
                    conn.Dispose();

                    //密碼加密
                    //col.emppasswd = dbobj.Encrypt(col.emppasswd);
                    //col.chkclass = col.emppasswd;
                    col.comid  = Session["tempid"].ToString();
                    col.bmodid = Session["tempid"].ToString();
                    //col.badddate = DateTime.Now;
                    col.bmoddate = DateTime.Now;
                    using (AitagBill_DBContext con = new AitagBill_DBContext())
                    {
                        con.billsubject.Add(col);
                        con.SaveChanges();

                        //系統LOG檔 //================================================= //
                        SqlConnection sysconn    = dbobj.get_conn("Aitag_DBContext");
                        string        sysrealsid = Request["sysrealsid"].ToString();
                        string        syssubname = dbobj.get_sysmenuname(sysconn, sysrealsid, "2");
                        string        sysnote    = "類別:" + col.comclass + "代碼名稱:" + col.subjecttitle;
                        dbobj.systemlog(sysconn, syssubname, sysnote, Session["tempid"].ToString(), Session["sldate"].ToString(), Session["sfip"].ToString(), sysflag);
                        sysconn.Close();
                        sysconn.Dispose();
                        //=================================================
                    }
                    string tmpform = "";
                    tmpform  = "<body onload=qfr1.submit();>";
                    tmpform += "<form name='qfr1' action='/billsubject/List' method='post'>";
                    tmpform += "<input type=hidden name='sysflag' id='sysflag' value='" + sysflag + "'>";
                    tmpform += "<input type=hidden name='page' id='page' value='" + page + "'>";
                    tmpform += "<input type=hidden name='orderdata' id='orderdata' value='" + orderdata + "'>";
                    tmpform += "<input type=hidden name='orderdata1' id='orderdata1' value='" + orderdata1 + "'>";
                    tmpform += "<input type=hidden id='qcomclass' name='qcomclass' value='" + qcomclass + "'>";
                    tmpform += "<input type=hidden id='qsubjecttitle' name='qsubjecttitle' value='" + qsubjecttitle + "'>";
                    tmpform += "<input type=hidden id='qitemcode' name='qitemcode' value='" + qitemcode + "'>";
                    tmpform += "</form>";
                    tmpform += "</body>";


                    return(new ContentResult()
                    {
                        Content = @"" + tmpform
                    });
                    // return RedirectToAction("List");
                }
            }
        }