Example #1
0
        public string insert(T12013 t12013, List <T12256> t12256)
        {
            string dt = "";

            try
            {
                dt = obj.insert(t12013, t12256);
            }
            catch (Exception e)
            {
                MethodBase m = MethodBase.GetCurrentMethod();
                obj.Log(m.ReflectedType.Name + "." + m.Name, "1", e.Message);
            }

            return(dt);
            //var Data = obj.insert(t12013, t12256);
            //return Data;
        }
 public ActionResult insert(T12013 t12013, List <T12256> t12256)
 {
     try
     {
         string site       = Session["T_SITE_CODE"].ToString();
         string emp        = Session["T_EMP_CODE"].ToString();
         var    data       = repository.insert(t12013, t12256);
         string JSONString = string.Empty;
         JSONString = JsonConvert.SerializeObject(data);
         return(Json(JSONString, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         err.SetServerErrorLog(ControllerContext.RouteData.Values["controller"].ToString(),
                               ControllerContext.RouteData.Values["action"].ToString(),
                               Session["T_ENTRY_USER"] == null ? "" : Session["T_ENTRY_USER"].ToString(), e.Message);
         return(Json(e.Message, JsonRequestBehavior.AllowGet));
     }
 }
Example #3
0
        public string insert(T12013 t12013, List <T12256> t12256)
        {
            string msg        = "";
            string Unit_count = "";
            bool   ist13      = false;
            int    count      = 0;
            string time       = DateTime.Now.TimeOfDay.Hours + DateTime.Now.TimeOfDay.Minutes.ToString();

            if (t12013.T_AUTO_ISSUE_ID == 0 || t12013.T_AUTO_ISSUE_ID == null)
            {
                //----------------------------------insert-----------------------------
                t12013.T_AUTO_ISSUE_ID = Int32.Parse(Query($"SELECT TO_NUMBER(NVL(MAX(T_AUTO_ISSUE_ID),0)+1) T_AUTO_ISSUE_ID FROM T12013").Rows[0]["T_AUTO_ISSUE_ID"].ToString());

                BeginTransaction();
                if (Command($"INSERT INTO T12013 (T_REQUEST_NO,T_PAT_NO,T_PRODUCT_CODE,T_UNITS_ISSUED,T_ANTI_A,T_ANTI_B,T_ANTI_D,T_CONTROL,T_CELLS_A,T_CELLS_B,T_BLOOD_GROUP,T_SC_I,T_SC_II,T_SC_III,T_DCT,T_AUTO_CONTROL,T_INTERPRETATION,T_TS_START_TIME,T_TS_END_TIME,T_TECH_CODE,T_REMARKS,T_BG_ND,T_BG_N,T_AUTO_ANTI,T_ALLO_ANTI,T_NON_SPEC,T_ANTI_TYPE_AUTO,T_AUTO_OTHERS,T_ANTI_TYPE_ALLO,T_ALLO_OTHERS,T_ANTI_FINAL,T_ANTI_FINAL1,T_ANTI_FINAL2,T_NONS_OTHERS,T_PHENO,T_D,T_CC,T_CS,T_EC,T_ES,T_KC,T_KS,T_JKA,T_JKB,T_FYA,T_FYB,T_M,T_N,T_SC,T_SS,T_LEA,T_LEB,T_ENTRY_USER,T_ENTRY_DATE,T_SITE_CODE,T_AUTO_ISSUE_ID) VALUES ('{t12013.T_REQUEST_NO}','{t12013.T_PAT_NO}','{t12013.T_PRODUCT_CODE}','{t12013.T_UNITS_ISSUED}','{t12013.T_ANTI_A}','{t12013.T_ANTI_B}','{t12013.T_ANTI_D}','{t12013.T_CONTROL}','{t12013.T_CELLS_A}','{t12013.T_CELLS_B}','{t12013.T_BLOOD_GROUP}','{t12013.T_SC_I}','{t12013.T_SC_II}','{t12013.T_SC_III}','{t12013.T_DCT}','{t12013.T_AUTO_CONTROL}', '{t12013.T_INTERPRETATION}','{t12013.T_TS_START_TIME}','{t12013.T_TS_END_TIME}','{t12013.T_TECH_CODE}','{t12013.T_REMARKS}','{t12013.T_BG_ND}','{t12013.T_BG_N}','{t12013.T_AUTO_ANTI}','{t12013.T_ALLO_ANTI}','{t12013.T_NON_SPEC}','{t12013.T_ANTI_TYPE_AUTO}','{t12013.T_AUTO_OTHERS}','{t12013.T_ANTI_TYPE_ALLO}','{t12013.T_ALLO_OTHERS}','{t12013.T_ANTI_FINAL}','{t12013.T_ANTI_FINAL1}','{t12013.T_ANTI_FINAL2}','{t12013.T_NONS_OTHERS}','{t12013.T_PHENO}','{t12013.T_D}','{t12013.T_CC}','{t12013.T_CS}','{t12013.T_EC}','{t12013.T_ES}','{t12013.T_KC}','{t12013.T_KS}','{t12013.T_JKA}','{t12013.T_JKB}','{t12013.T_FYA}','{t12013.T_FYB}','{t12013.T_M}','{t12013.T_N}','{t12013.T_SC}','{t12013.T_SS}','{t12013.T_LEA}','{t12013.T_LEB}','{t12013.T_ENTRY_USER}','{t12013.T_ENTRY_DATE}','{t12013.T_SITE_CODE}',{t12013.T_AUTO_ISSUE_ID})")
                    )
                {
                    CommitTransaction();
                    ist13 = true;
                }
                else
                {
                    RollbackTransaction();
                }
                if (t12256 != null)
                {
                    if (t12256.Count > 0)
                    {
                        foreach (var t56 in t12256)
                        {
                            t56.T_AUTO_ISSUE_DET_ID = Int32.Parse(Query($"SELECT TO_NUMBER(NVL(MAX(T_AUTO_ISSUE_DET_ID),0)+ 1) T_AUTO_ISSUE_DET_ID FROM T12256").Rows[0]["T_AUTO_ISSUE_DET_ID"].ToString());
                            BeginTransaction();
                            if (Command($"INSERT INTO T12256 (T_ENTRY_USER,T_ENTRY_DATE,T_BB_STOCK_ID,T_IS,T_C,T_AHG,T_CCC,T_GEL_AHG,T_COMPATIBLE,T_AUTO_ISSUE_ID,T_AUTO_ISSUE_DET_ID) VALUES ('{t12013.T_ENTRY_USER}',TRUNC(SYSDATE),'{t56.T_BB_STOCK_ID}','{t56.T_IS}', '{t56.T_C}', '{t56.T_AHG}','{t56.T_CCC}','{t56.T_GEL_AHG}','{t56.T_COMPATIBLE}','{t12013.T_AUTO_ISSUE_ID}','{t56.T_AUTO_ISSUE_DET_ID}')") && Command($"UPDATE T12223 SET T_UPD_DATE=TRUNC(SYSDATE), T_UPD_USER ='******',T_USED_FLG=1 WHERE T_BB_STOCK_ID={t56.T_BB_STOCK_ID}"))
                            {
                                CommitTransaction();
                                count++;
                            }
                            else
                            {
                                RollbackTransaction();
                            }
                        }
                    }
                    if (t12256.Count != count)
                    {
                        ist13 = false;
                    }
                }


                msg = ist13 ? "Data inserted Successfully" : "Data not inserted";
            }
            else
            {
                //----------------------------------update-----------------------------
                BeginTransaction();
                if (Command($"UPDATE T12013  SET T_REQUEST_NO='{t12013.T_REQUEST_NO}',T_PAT_NO='{t12013.T_PAT_NO}',T_PRODUCT_CODE='{t12013.T_PRODUCT_CODE}',T_UNITS_ISSUED='{t12013.T_UNITS_ISSUED}',T_ANTI_A='{t12013.T_ANTI_A}',T_ANTI_B='{t12013.T_ANTI_B}',T_ANTI_D='{t12013.T_ANTI_D}',T_CONTROL='{t12013.T_CONTROL}',T_CELLS_A='{t12013.T_CELLS_A}',T_CELLS_B='{t12013.T_CELLS_B}',T_BLOOD_GROUP='{t12013.T_BLOOD_GROUP}',T_SC_I='{t12013.T_SC_I}',T_SC_II='{t12013.T_SC_II}',T_SC_III='{t12013.T_SC_III}',T_DCT='{t12013.T_DCT}',T_AUTO_CONTROL='{t12013.T_AUTO_CONTROL}',T_INTERPRETATION='{t12013.T_INTERPRETATION}',T_TS_START_TIME='{t12013.T_TS_START_TIME}',T_TS_END_TIME='{t12013.T_TS_END_TIME}',T_TECH_CODE='{t12013.T_TECH_CODE}',T_REMARKS='{t12013.T_REMARKS}',T_BG_ND='{t12013.T_BG_ND}',T_BG_N='{t12013.T_BG_N}',T_AUTO_ANTI='{t12013.T_AUTO_ANTI}',T_ALLO_ANTI='{t12013.T_ALLO_ANTI}',T_NON_SPEC='{t12013.T_NON_SPEC}',T_ANTI_TYPE_AUTO='{t12013.T_ANTI_TYPE_AUTO}',T_AUTO_OTHERS='{t12013.T_AUTO_OTHERS}',T_ANTI_TYPE_ALLO='{t12013.T_ANTI_TYPE_ALLO}',T_ALLO_OTHERS='{t12013.T_ALLO_OTHERS}',T_ANTI_FINAL='{t12013.T_ANTI_FINAL}',T_ANTI_FINAL1='{t12013.T_ANTI_FINAL1}',T_ANTI_FINAL2='{t12013.T_ANTI_FINAL2}',T_NONS_OTHERS='{t12013.T_NONS_OTHERS}',T_PHENO='{t12013.T_PHENO}',T_D='{t12013.T_D}',T_CC='{t12013.T_CC}',T_CS='{t12013.T_CS}',T_EC='{t12013.T_EC}',T_ES='{t12013.T_ES}',T_KC='{t12013.T_KC}',T_KS='{t12013.T_KS}',T_JKA='{t12013.T_JKA}',T_JKB='{t12013.T_JKB}',T_FYA='{t12013.T_FYA}',T_FYB='{t12013.T_FYB}',T_M='{t12013.T_M}',T_N='{t12013.T_N}',T_SC='{t12013.T_SC}',T_SS='{t12013.T_SS}',T_LEA='{t12013.T_LEA}',T_LEB='{t12013.T_LEB}',T_ENTRY_USER='******',T_ENTRY_DATE='{t12013.T_ENTRY_DATE}',T_SITE_CODE='{t12013.T_SITE_CODE}' WHERE T_AUTO_ISSUE_ID={t12013.T_AUTO_ISSUE_ID}")
                    )
                {
                    CommitTransaction();
                    ist13 = true;
                }
                else
                {
                    RollbackTransaction();
                }
                if (t12256 != null)
                {
                    if (t12256.Count > 0)
                    {
                        foreach (var t56 in t12256)
                        {
                            BeginTransaction();
                            if (t56.T_AUTO_ISSUE_DET_ID == null || t56.T_AUTO_ISSUE_DET_ID == 0)

                            {
                                t56.T_AUTO_ISSUE_DET_ID = Int32.Parse(Query($"SELECT TO_NUMBER(NVL(MAX(T_AUTO_ISSUE_DET_ID),0)+ 1) T_AUTO_ISSUE_DET_ID FROM T12256").Rows[0]["T_AUTO_ISSUE_DET_ID"].ToString());

                                if (Command($"INSERT INTO T12256 (T_ENTRY_USER,T_ENTRY_DATE,T_BB_STOCK_ID,T_IS,T_C,T_AHG,T_CCC,T_GEL_AHG,T_COMPATIBLE,T_AUTO_ISSUE_ID,T_AUTO_ISSUE_DET_ID) VALUES ('{t12013.T_ENTRY_USER}',TRUNC(SYSDATE),'{t56.T_BB_STOCK_ID}','{t56.T_IS}', '{t56.T_C}', '{t56.T_AHG}','{t56.T_CCC}','{t56.T_GEL_AHG}','{t56.T_COMPATIBLE}','{t12013.T_AUTO_ISSUE_ID}','{t56.T_AUTO_ISSUE_DET_ID}')") && Command($"UPDATE T12223 SET T_UPD_DATE=TRUNC(SYSDATE), T_UPD_USER ='******',T_USED_FLG=1 WHERE T_BB_STOCK_ID={t56.T_BB_STOCK_ID}"))
                                {
                                    CommitTransaction();
                                    count++;
                                }
                                else
                                {
                                    RollbackTransaction();
                                }
                            }
                            else if (t56.T_AUTO_ISSUE_DET_ID != null)
                            {
                                DataTable dtIssue = Query($"SELECT T23.T_UNIT_NO,T56.T_ISSUE_FLAG FROM T12256 T56 INNER JOIN T12223 T23 ON T56.T_BB_STOCK_ID=T23.T_BB_STOCK_ID WHERE T56.T_AUTO_ISSUE_DET_ID ='{t56.T_AUTO_ISSUE_DET_ID}'");
                                //if (dtIssue.Rows.Count>0)
                                //{
                                if (string.IsNullOrEmpty(dtIssue.Rows[0]["T_ISSUE_FLAG"].ToString()))
                                {
                                    if (Command($"UPDATE T12256  SET T_UPD_USER = '******' , T_UPD_DATE = TRUNC(SYSDATE), T_BB_STOCK_ID='{t56.T_BB_STOCK_ID}', T_IS='{t56.T_IS}', T_C = '{t56.T_C}',T_AHG='{t56.T_AHG}',T_CCC='{t56.T_CCC}',T_GEL_AHG='{t56.T_GEL_AHG}',T_COMPATIBLE='{t56.T_COMPATIBLE}' WHERE T_AUTO_ISSUE_DET_ID='{t56.T_AUTO_ISSUE_DET_ID}'"))
                                    {
                                        CommitTransaction();
                                        count++;
                                    }
                                    else
                                    {
                                        RollbackTransaction();
                                    }
                                }
                                else
                                {
                                    CommitTransaction();
                                    Unit_count += dtIssue.Rows[0]["T_UNIT_NO"] + ",";
                                    count++;
                                }
                                //}
                            }
                            else
                            {
                                count++;
                            }
                        }
                    }
                    if (t12256.Count != count)
                    {
                        ist13 = false;
                    }
                }

                //Unit_count= Unit_count!=""? Unit_count.Remove(Unit_count.Length - 1):"";
                string msgWithUnit = Unit_count != "" ? "This " + Unit_count.Remove(Unit_count.Length - 1) + " Units are issued. Can not be updated. ":"";
                msg = ist13 ? msgWithUnit + "Data updated Successfully" : "Data not updated";
            }
            return(msg);
        }