Пример #1
0
        public static void UpdateChotCa(DataObject.ChotCa obj, String ngayChot, String nguoiChot)
        {
            // 1 : Lưu thành công
            // 2 : Lưu thông tin không thành công trạng thái đang xử lý
            // 3 : Lưu thông tin không thành công trạng thái hoàn thành
            // 4  : Lưu thông tin không thành công trạng thái Đang xử lý về Chưa xử lý
            SqlConnection conn     = Common.Connection.SqlConnect();
            String        strCheck = "Select TienThuDuoc FROM ChotCa where  convert(date,CONVERT(VARCHAR(10),NgayChot, 103),103) = convert(date,CONVERT(VARCHAR(10),'" + ngayChot + "' , 103),103) AND NguoiChot = N'" + nguoiChot + "'";
            SqlCommand    cmdCheck = new SqlCommand(strCheck);

            cmdCheck.CommandType = CommandType.Text;
            cmdCheck.Connection  = conn;
            conn.Open();
            object money = cmdCheck.ExecuteScalar();

            conn.Close();
            Decimal m = Convert.ToDecimal(money);

            obj.TienThuDuoc = obj.TienThuDuoc + m;
            String     Insert = "Update  ChotCa set  TienThuDuoc = " + obj.TienThuDuoc + " ,NguoiChot = N'" + obj.NguoiChot + "' ,GioChot ='" + obj.GioChot + "' where convert(date,CONVERT(VARCHAR(10),NgayChot, 103),103) = convert(date,CONVERT(VARCHAR(10),'" + ngayChot + "' , 103),103) AND NguoiChot = N'" + nguoiChot + "'";
            SqlCommand cmd    = new SqlCommand(Insert);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn;
            conn.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            conn.Close();
        }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            String type     = context.Request.Form["type"].ToString();
            String jsonData = context.Request.Form["data"].ToString();

            DataObject.DeptObject obj = new JavaScriptSerializer().Deserialize <DataObject.DeptObject>(jsonData);
            if (type == "InsertChotCaReturnId")
            {
                try
                {
                    //String NgayChot = context.Request.Form["NgayChot"].ToString();
                    //DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    String            TienThuDuoc = context.Request.Form["TienThuDuoc"].ToString();
                    DataObject.ChotCa chotca      = new DataObject.ChotCa();
                    chotca.TienThuDuoc = TienThuDuoc != "" ? Convert.ToDecimal(TienThuDuoc) : 0;
                    chotca.NgayChot    = DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    chotca.NguoiChot   = HttpContext.Current.Session["UserName"].ToString();
                    chotca.GioChot     = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
                    int result = Servies.ChotCaServices.InsertChotCaReturnId(chotca, DateTime.Now.ToString("dd/MM/yyyy"), chotca.NguoiChot);
                    context.Response.ContentType = "text/plain";
                    context.Response.Write("insert data success");
                }
                catch (Exception e)
                {
                    context.Response.ContentType = "text/plain";
                    context.Response.Write("Error");
                }
            }
            else if (type == "ViewChotCa")
            {
                try
                {
                    String    NguoiChot = context.Request.Form["NguoiChot"].ToString();
                    String    NgayChot  = context.Request.Form["NgayChot"].ToString();
                    DataTable dt        = Servies.ChotCaServices.ViewChotCa(NguoiChot, NgayChot);
                    context.Response.ContentType = "application/json";
                    context.Response.Write(JsonConvert.SerializeObject(dt));
                }
                catch (Exception e)
                {
                    context.Response.ContentType = "text/plain";
                    context.Response.Write("Error");
                }
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("Hello");
            }
        }
Пример #3
0
        public static void UpdateChotCa(DataObject.ChotCa obj, String ngayChot)
        {
            // 1 : Lưu thành công
            // 2 : Lưu thông tin không thành công trạng thái đang xử lý
            // 3 : Lưu thông tin không thành công trạng thái hoàn thành
            // 4  : Lưu thông tin không thành công trạng thái Đang xử lý về Chưa xử lý
            SqlConnection conn   = Common.Connection.SqlConnect();
            String        Insert = "Update  ChotCa set  TienThuDuoc = " + obj.TienThuDuoc + " ,NguoiChot = N'" + obj.NguoiChot + "' ,GioChot ='" + obj.GioChot + "' where convert(date,CONVERT(VARCHAR(10),NgayChot, 103),103) = convert(date,CONVERT(VARCHAR(10),'" + ngayChot + "' , 103),103)";
            SqlCommand    cmd    = new SqlCommand(Insert);

            cmd.CommandType = CommandType.Text;
            cmd.Connection  = conn;
            conn.Open();
            cmd.ExecuteNonQuery();
            cmd.Connection.Close();
            conn.Close();
        }
Пример #4
0
 public String InsertChotCaReturnId(String type, String data, String TienThuDuoc, String lstId)
 {
     try
     {
         DataObject.ChotCa chotca = new DataObject.ChotCa();
         chotca.TienThuDuoc = TienThuDuoc != "" ? Convert.ToDecimal(TienThuDuoc) : 0;
         chotca.NgayChot    = DateTime.ParseExact(DateTime.Now.ToString("dd/MM/yyyy"), "dd/MM/yyyy", CultureInfo.InvariantCulture);
         chotca.NguoiChot   = this.Session["UserName"].ToString();
         chotca.GioChot     = DateTime.Now.Hour + ":" + DateTime.Now.Minute + ":" + DateTime.Now.Second;
         int result = Servies.ChotCaServices.InsertChotCaReturnId(chotca, DateTime.Now.ToString("dd/MM/yyyy"), chotca.NguoiChot);
         Servies.ChotCaServices.UpdateLoTrinhShipperByFlag(lstId);
         return(result.ToString());
     }
     catch (Exception e)
     {
         e.ToString();
         return("0");
     }
 }
Пример #5
0
        public static int InsertChotCaReturnId(DataObject.ChotCa obj, String ngayChot, String nguoiChot)
        {
            int           check    = 0;
            SqlConnection conn     = Common.Connection.SqlConnect();
            String        strCheck = "Select Top 1 ID FROM ChotCa where  convert(date,CONVERT(VARCHAR(10),NgayChot, 103),103) = convert(date,CONVERT(VARCHAR(10),'" + ngayChot + "' , 103),103) AND NguoiChot = N'" + nguoiChot + "'";
            SqlCommand    cmdCheck = new SqlCommand(strCheck);

            cmdCheck.CommandType = CommandType.Text;
            cmdCheck.Connection  = conn;
            conn.Open();
            object insertedCheck = cmdCheck.ExecuteScalar();

            cmdCheck.Connection.Close();
            conn.Close();
            if (insertedCheck != null)
            {
                check = Convert.ToInt16(insertedCheck);
            }
            if (check == 0)
            {
                String     Insert = "INSERT INTO ChotCa (NgayChot,TienThuDuoc,NguoiChot,GioChot) VALUES (@NgayChot,@TienThuDuoc,@NguoiChot,@GioChot);Select @@IDENTITY as newId";
                SqlCommand cmd    = new SqlCommand(Insert);
                cmd.CommandType = CommandType.Text;
                cmd.Connection  = conn;
                cmd.Parameters.AddWithValue("@NgayChot", obj.NgayChot);
                cmd.Parameters.AddWithValue("@TienThuDuoc", obj.TienThuDuoc);
                cmd.Parameters.AddWithValue("@NguoiChot", obj.NguoiChot);
                cmd.Parameters.AddWithValue("@GioChot", obj.GioChot);
                conn.Open();
                object insertedID = cmd.ExecuteScalar();
                cmd.Connection.Close();
                conn.Close();
                return(Convert.ToInt32(insertedID));
            }
            else
            {
                UpdateChotCa(obj, ngayChot, nguoiChot);
                return(0);
            }
        }