Exemple #1
0
        public static string CheckUser(string id, string user, string passwd)
        {
            einvoiceEntities db = new einvoiceEntities();
            var data            = (from p in db.EI_SYS_USERDATA
                                   where p.tax_number == id && p.user_id == user
                                   select p).ToList();

            if (data.Count > 0)
            {
                if (data[0].user_pwd != passwd)
                {
                    return(ErrMeg.ErrString("1004", ""));
                }
            }
            else
            {
                return(ErrMeg.ErrString("1001", "查無使用者資料"));
            }

            return("");
        }
Exemple #2
0
        public static string Invoice_GetTrackList(string id, int year, string user, int period, int size)
        {
            int i = 0;

            using (einvoiceEntities db = new einvoiceEntities())
            {
                var data = db.EI_INV_USABLEDATA.Where(o => o.tax_number == id &&
                                                      o.year == year.ToString() &&
                                                      o.period == period.ToString() &&
                                                      o.status == "Y" &&
                                                      (o.user_account == "ALL" || o.user_account == user)).
                           OrderBy(o => o.begin_no).ToList();

                int    nowsize = size;
                string re      = "";
                foreach (var item in data)
                {
                    re += item.header + ",";

                    //已有開立過的資料
                    if (!string.IsNullOrEmpty(data[i].now_no.ToString()))
                    {
                        // 此筆張數
                        int totalecount = int.Parse(item.end_no) - int.Parse(item.now_no);
                        re += (int.Parse(item.now_no) + 1).ToString().PadLeft(8, '0') + ",";

                        // 所取張數大於此筆張數
                        if (nowsize > totalecount)
                        {
                            item.now_no = item.end_no;
                            nowsize     = nowsize - totalecount;
                        }
                        else
                        {
                            item.now_no = (int.Parse(item.now_no) + nowsize).ToString().PadLeft(8, '0');
                            nowsize     = 0;
                        }
                    }
                    else //未開立過的資料
                    {
                        // 此筆張數
                        int totalecount = int.Parse(item.end_no) - int.Parse(item.begin_no) + 1;
                        re += item.begin_no + ",";

                        // 所取張數大於此筆張數
                        if (nowsize > totalecount)
                        {
                            item.now_no = item.end_no;
                            nowsize     = nowsize - totalecount;
                        }
                        else
                        {
                            item.now_no = (int.Parse(item.begin_no) + nowsize - 1).ToString().PadLeft(8, '0');
                            nowsize     = 0;
                        }
                    }

                    re              += item.now_no + ",";
                    item.modify_dt   = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    item.modify_user = user;

                    // 分配完跳出
                    if (nowsize == 0)
                    {
                        break;
                    }
                    i++;
                }
                db.SaveChanges();

                re = re.TrimEnd(',');
                return(ErrMeg.StatusString2("0000", "取票成功", re, size));
            }
        }